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

Rupert Germann rupi at gmx.li
Sun Jun 7 21:34:15 CEST 2009


hi,

I found some more things that I'd change in this patch and compiled them to
a new patch: v3

differences to v2
- removed "&& $GLOBALS['LANG']->lang == 'default' " from the condition
because if there's no be_user logged in $GLOBALS['LANG']->lang is
always 'default'
- changed some comments
- removed strlen() check
- changed the way the loginlabels are compared (to get rid of that long
line :-) )
- added a toDo comment to motivate someone (masi?) to integrate the stuff
masi suggested below later.

I suggest to commit the v3 patch as it is because it is already a big step
in the right direction and it definetively improves the situation for all
people using browsers that send a HTTP_ACCEPT_LANGUAGE like en,de,fr
(possibly more).
the 100% solution should be applied afterwards in a new patch.

greets
rupert


Martin Kutschker wrote:
> 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