Page 1 of 1
languages into templates? [solved]
Posted: Mon Jun 11, 2007 9:41 am
by pumuklee
hi
i want to use the language files in my cmsms
the usage
$this->Lang("LINK_TO_HOMEPAGE")
if i want to appear in my template
than i must use
$this->smarty->assign("LINK_TO_HOMEPAGE",$this->Lang("LINK_TO_HOMEPAGE"));
and in the template use
{$LINK_TO_HOMEPAGE}
is there another possibility?
because i have 100 lang[] array elements
and i dont want to write 100 assign row
is there another possibility to assign all?
or to not use assign
to include directly into the template?
thanks
Re: languages into templates?
Posted: Mon Jun 11, 2007 10:33 am
by alby
pumuklee wrote:
i want to use the language files in my cmsms
the usage
$this->Lang("LINK_TO_HOMEPAGE")
if i want to appear in my template
than i must use
$this->smarty->assign("LINK_TO_HOMEPAGE",$this->Lang("LINK_TO_HOMEPAGE"));
and in the template use
{$LINK_TO_HOMEPAGE}
is there another possibility?
because i have 100 lang[] array elements
and i dont want to write 100 assign row
is there another possibility to assign all?
or to not use assign
to include directly into the template?
If you have a possibility, load full array and assign it:
$this->smarty->assign_by_ref("LANG_ARRAY",$arr_lang);
and in template:
{$LANG_ARRAY.key}
This output value of $arr_lang['key']
or UDT: mylang
Code: Select all
$arr_lang = array(
'key1'=>'val1',
'key2'=>'val2',
'key3'=>'va3',
);
if (isset($params[key])) echo $arr_lang[$params[key]];
echo ''
and in template (output val2):
{mylang key=key2}
Alby
Re: languages into templates?
Posted: Mon Jun 11, 2007 12:50 pm
by pumuklee
yes you have right
but i want ot use this Lang() function
because it is working for many language file
my question is that i can be assign more variables
im not sure because i dont find a proper documnetation for this
the function can be called with some parameters
but is didnt find what kind of these
thanks
Re: languages into templates?
Posted: Mon Jun 11, 2007 12:59 pm
by pumuklee
ok
i see that this $params is used for vsprintf for string for
about the function Lang() i see that it can be load just one define from $lang array
any idea how can i load more or all varables at one time
because to write az assign line for every 100 variable it is a little bit complicated
thanks
Re: languages into templates?
Posted: Mon Jun 11, 2007 1:09 pm
by alby
pumuklee wrote:
i see that this $params is used for vsprintf for string for
about the function Lang() i see that it can be load just one define from $lang array
any idea how can i load more or all varables at one time
because to write az assign line for every 100 variable it is a little bit complicated
Why not include file lang of your interest?
Alby
Re: languages into templates?
Posted: Mon Jun 11, 2007 1:11 pm
by pumuklee
i found a solution
in mymodule.module.php
i created a new function
function lang_var_list($varlist_array)
{
for($i=0;$ismarty->assign($varlist_array[$i],$this->Lang($varlist_array[$i]));
}
}
aftre that in the page where i want to assign more variables
i used in this way
$varlist_array = array('ADMIN_NEW_ORDERS','ADMIN_SETTINGS_GENERAL','ADMIN_SHIPPING_PAGE');
$this->lang_var_list($varlist_array);
in this way i dont need to write an assign row for every variable
thanks for the helps
any other idea?