[TYPO3-translators] setlocale() in TCA itemsProcFunc
Felix Kiesewetter
info at felixkiesewetter.de
Tue Jul 1 14:42:00 CEST 2014
I just couldn't find a solution for this.
I have a plugin that creates a select box in the TCA and adds it to tt_news. In the select box, there are date() formatted timestamps that work well, except for the fact that they are in English only. I need them to be localised (e.g. date(%l, $ts) to be displayed as "Dienstag" instead of "Tuesday"). I tried to use the following:
setlocale(LC_ALL, 'de_DE');
setlocale(LC_ALL, 'de-DE');
setlocale(LC_ALL, 'de_DE at euro');
setlocale(LC_ALL, 'de');
But they get ignored every time.
This is my ext_tables.php part:
'config' => array (
'type' => 'select',
'itemsProcFunc' => 'tx_newscal_tca->recurring',
'default' => 0
)
This is the class that's being used to add to the item list:
class tx_newscal_tca {
function recurring($config) {
setlocale (LC_ALL, 'de_DE at euro', 'de_DE', 'de', 'ge');
$datetime = $config['row']['datetime'];
$F = date('F', $datetime);
$d = date('d', $datetime);
$l = date('l', $datetime);
$optionList = array();
$optionList[] = array(
0 => $GLOBALS['LANG']->sL('LLL:EXT:newscal/locallang.xml:tcalabels.recurring.0'),
1 => 0
); // Once
$optionList[] = array(
0 => str_replace('%l', $l, $GLOBALS['LANG']->sL('LLL:EXT:newscal/locallang.xml:tcalabels.recurring.1')),
1 => 1
); // Weekly
$optionList[] = array(
0 => str_replace('%d', $d, $GLOBALS['LANG']->sL('LLL:EXT:newscal/locallang.xml:tcalabels.recurring.2')),
1 => 2
); // Monthly
$optionList[] = array(
0 => str_replace(array('%d', '%F'), array($d, $F), $GLOBALS['LANG']->sL('LLL:EXT:newscal/locallang.xml:tcalabels.recurring.3')),
1 => 3
); // Yearly
$config['items'] = array_merge($config['items'], $optionList);
return $config;
}
}
More information about the TYPO3-translators
mailing list