[FLOW3-general] Labels translations based on user's language

Steffen Wickham steffen at gaming-inc.de
Thu Jan 3 17:41:49 CET 2013


Your welcome! :)



Am 03.01.2013 17:40, schrieb Sergio:
> Thank you very much for all the explanation, Steffan!
>
> It worked. I just only needed to understand the "locale" property, but you
> gave me an idea for setting the user's language when creating it, based on
> web browser's language ;-)
>
> Thanks!
> Sergio
>
>
> 2013/1/3 Steffen Wickham <steffen at gaming-inc.de>
>
>> Hello Sergio,
>>
>> to detect which language will be accepted by the client you can detect
>> it by using the following code:
>>     $detector = new \TYPO3\Flow\I18n\Detector();
>>     $language =
>> $detector->detectLocaleFromHttpHeader($_SERVER['HTTP_ACCEPT_LANGUAGE']);
>>     $view->assign('language', $language->getLanguage());
>>
>> (for Flow 1.1 change first line to "$detector = new
>> \TYPO3\FLOW3\I18n\Detector();")
>>
>> Now you have to provide the language variable to the locale attribute of
>> each <f:translate> in your template. For example:
>> <f:translate id="indexAction.noGamesFound" locale="{language}"
>> source="Match" />
>>
>> The I18n/l10n part of the framework will choose the correct XLIFF file
>> (in this case "Match.xlf" in Resources/Private/Translations/<language>/
>> directory) and tries to put in the correct translation for the
>> <f:translate> part.
>>
>> So for you it's the best way to check if there is already a language in
>> your User class set and use this, otherwise try to detect it by the
>> method above.
>>
>> Greetings
>> Steffen
>>
>>
>> Am 03.01.2013 17:02, schrieb Sergio:
>>> Hi list,
>>>
>>> I have a "User" class that extends "Person" class (Party extension) and
>>> I've added "language" field as the user's prefered language for the
>> website.
>>> I've read this guide about internationalization:
>>>
>> http://flow.typo3.org/documentation/guide/partiii/internationalization.html
>>> And I understand XLIFF formats and I've got all my labels ready to
>>> translate, but how do I do the website detects this user's language?
>>>
>>> Any hints would be welcome.
>>>
>>> Thanks in advance,
>>> Sergio
>>> _______________________________________________
>>> FLOW3-general mailing list
>>> FLOW3-general at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>> _______________________________________________
>> FLOW3-general mailing list
>> FLOW3-general at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list