Select Menu and Internationalization
How do you properly set up a select menu so that the dropdown choices can be viewed in a different language when a language pack is installed, but the logic still works? eg: 'Unread','Pending','Ok','Closed' are English.
Code:
'unread' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_realestate_contactor']['unread'],
'inputType' => 'select',
'options' => array('Unread','Pending','Ok','Closed'),
'eval' => array('tl_class'=>'w50'),
'filter' => true,
'sorting' => true,
'save_callback' => array
(
array('tl_realestate_contactor', 'markAsRead')
),
'flag' => 12
),
I use the dropdowns in code, for example
Code:
public function markAsRead($varValue)
{
if($varValue == "Unread")
{
$varValue = "Pending";
}
return $varValue;
}
EDIT: Why the heck does my Code always go spastic when I cut/paste/post it wrapped in the code tags???
Re: Select Menu and Internationalization
Ehm, is it me, but you can use language strings... So you can use values, such as unread, pending and then define display value for this for each language in languages/en/tl_.php
Re: Select Menu and Internationalization
Code:
'options' => array($GLOBALS['TL_LANG']['tl_realestate_contactor']['A'],$GLOBALS['TL_LANG']['tl_realestate_contactor']['B'],$GLOBALS['TL_LANG']['tl_realestate_contactor']['C'],$GLOBALS['TL_LANG']['tl_realestate_contactor']['D']),
Code:
$GLOBALS['TL_LANG']['tl_realestate_contactor']['A'] = 'Unread';
$GLOBALS['TL_LANG']['tl_realestate_contactor']['B'] = 'Pending';
Code:
public function markAsRead($varValue)
{
if($varValue == $GLOBALS['TL_LANG']['tl_realestate_contactor']['A'])
{
$varValue = $GLOBALS['TL_LANG']['tl_realestate_contactor']['B'];
}
return $varValue;
}
Like so?
Re: Select Menu and Internationalization
Hi ramjet
you need to use the 'reference' configuration option
from:
http://www.contao.org/reference.html#fields
"Array that holds the options labels. Typically a reference to the global language array."
Some time ago I wrote an article that covers also this topic
It is here http://zedseries.blogspot.com/2009/1...e-options.html
take a look at 'printable' field in tl_article dca or 'rgxp' in tl_form_field dca
hope this helps
Re: Select Menu and Internationalization
Thats absolutely perfect ga.n, thank you.
I'll have a good look over your site in the next few days (i did a while ago but most things were way over my head then.... hopefully I'll be a bit more clued in now)
Cheers very much, murray :D :D