#39597Multiple locale names for TS config.locale_all
Description
PHP setlocale() supports multiple locale names as fallback. This is not yet supported for the TypoScript config value “config.locale_all”.
Affected are all Typo3 versions at least until the 7th of August 2012 (4.5.17, 4.6.10 4.7.2 6.0.0alpha3).
E.g.:
// Works in PHP since version 4.3.0
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
setlocale(LC_ALL, array('de_DE@euro', 'de_DE', 'deu_deu'));
# this will fail in TS-Setup config.locale_all = de_DE@euro, de_DE, deu_deu
Possible solution (working, but not examined completely (especially the workaround for turkish locales)):
Function tslib_fe::settingLocale() could use t3lib_div::trimExplode() to support multiple values for setlocale().
function settingLocale() {
// Setting locale
if ($this->config['config']['locale_all']) {
# Change by René Fritz, 22/10 2002
# there's a problem that PHP parses float values in scripts wrong if the locale LC_NUMERIC is set to something with a comma as decimal point
# this does not work in php 4.2.3
#setlocale('LC_ALL',$this->config['config']['locale_all']);
#setlocale('LC_NUMERIC','en_US');
# so we set all except LC_NUMERIC
// Support multiple names for setlocale
$locale = t3lib_div::trimExplode(',', $this->config['config']['locale_all']);
$locale = setlocale(LC_COLLATE, $locale);
if ($locale) {
// PHP fatals with uppercase I characters in method names with turkish locale LC_CTYPE
// Seems to be fixed in PHP 5.4.5 (19-Jul-2012)
// @see http://bugs.php.net/bug.php?id=18556
if ((version_compare(PHP_VERSION, '5.4.5') >= 0) || substr($locale, 0, 2) != 'tr' && substr($locale, 0, 7) != 'Turkish') {
setlocale(LC_CTYPE, $locale);
}
setlocale(LC_MONETARY, $locale);
setlocale(LC_TIME, $locale);
$this->localeCharset = $this->csConvObj->get_locale_charset($locale);
} else {
$GLOBALS['TT']->setTSlogMessage('Locale "'.htmlspecialchars($this->config['config']['locale_all']).'" not found.', 3);
}
}
}
Maybe the mentioned problems concerning LC_ALL & LC_NUMERIC are solved, so the function could be completely refactored.