languages into templates? [solved]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
pumuklee

languages into templates? [solved]

Post 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
Last edited by pumuklee on Mon Jun 11, 2007 1:11 pm, edited 1 time in total.
alby

Re: languages into templates?

Post 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
Last edited by alby on Mon Jun 11, 2007 10:43 am, edited 1 time in total.
pumuklee

Re: languages into templates?

Post 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
pumuklee

Re: languages into templates?

Post 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
alby

Re: languages into templates?

Post 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
pumuklee

Re: languages into templates?

Post 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?
Locked

Return to “Modules/Add-Ons”