[TYPO3-core] RFC #11293: Login page is not translatable

Martin Kutschker masi-no at spam-typo3.org
Sun Jun 7 20:47:56 CEST 2009


Benjamin Mack schrieb:
> Hey,
> 
> this is a SVN patch request.
> 
> Type: feature
> 
> BT reference: http://bugs.typo3.org/view.php?id=11293
> 
> Problem:
> the login page is not translatable. The labels are hardcoded and taken
> from the TYPO3_CONF_VARS['BE']['loginLabels']. However, through
> modifications in init.php, the $LANG object is now available on the
> login screen as well.

Great, but this is not entirely correct. First of all I want to state
that the Accept-language header is a bit more complicated than the
implementation assumes:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4

Though I have to admit that probably only a few problems will arise in
not adhering to the quality parameter.

More troublesome is the fact that the implementation does not take into
account that not all of TYPO3's language codes are ISO code. Also some
of the language codes must regard the country part of the code as well.

// get all languages where TYPO3 code is the same as the ISO code
$typo3Languages = array();
foreach ($GLOBALS['LANG']->csConvObj->charSetArray
   as $typo3Lang => $charSet) {
	$languages[$typo3Lang] = $typo3Lang;
}
// get all languages where TYPO3 code differs from ISO code
// or needs the country part
foreach ($GLOBALS['LANG']->csConvObj->isoArray
   as $typo3Lang => $isoLang) {
	$isoLanguages[join('-', explode('_', $isoLang))] = $typo3Lang;
}

$typo3Language = '';
list($preferredLanguages) =
  t3lib_div::explode(',',
    t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
foreach ($preferredLanguages as $preferredLanguage) {
  if ($isoLanguages[$preferredLanguage]) {
    $typo3Language = $isoLanguages[$preferredLanguage];
    break;
  }
  list($prefLanguage,$prefCountry) = explode('-', $preferredLanguage);
  if ($isoLanguages[$prefLang]) {
    $typo3Language = $isoLanguages[$prefLang];
    break;
  }
}
if (!$typo3Language || $typo3Language == 'en') {
  $typo3Language = 'default';
}

This (untested) code solves issue #2 and leaves issue #1 as an excercise
for the reader ;)

Ideally the code will go to t3lib_cs (or t3lib_div) so someone can add
language detection to FE as well.

Masi


More information about the TYPO3-team-core mailing list