[TYPO3-mvc] [SPAM FortiMail] Re: eID and Translations

Chris Wolff - AERTiCKET AG cwolff at aer.de
Wed Oct 29 09:31:23 CET 2014


Hi,
the Language configuration is done in Typoscript Setup therefore you need to initalize the Typoscript setup for a given Page.
But i this would take a lot of time. I would rather send another parameter along the ajax request with the language key

AJAX URL : ?eID=tx_myext&key=my_key_for_translation&lang=de

*** PHP **'
$lang = substr($lang,0,2); // shortening the given language code to 2 chars as this is what typo3 uses.
// make shure wie have a a string that looks like a language code. (eg letters only lowercase)
If(!preg_match('^[a-z]{2}$ ',$lang ){die('invalid language'); 
tslib_eidtools::initLanguage($lang);

*** /php ***

this would eleminate the case statment. And it would be future proof as all typo3 languages are supported.

Now your javascript frontend needs to now which language it runs in.
But this should be easy to get. As you send this information already along in the html tag as lang attribute.

<html lang="de_DE" />

Regards chris


-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von g4-lisz at tonarchiv.ch
Gesendet: Dienstag, 28. Oktober 2014 19:06
An: Gion Koch; TYPO3 v4 MVC project
Betreff: [SPAM FortiMail] Re: [TYPO3-mvc] eID and Translations

On 10/28/2014 05:29 PM, Gion Koch wrote:
> Greetings,
>
>
> Currently I'm stuck with getting a translated message from an Ajax 
> Request via eID. Everything works as it should, but not the 
> translation part.
> I stumbled already several times over this issue.
> As a workaround I used an ugly hack:
> - including the sys_language_uid as hidden field
> - send it along with every ajax call
> - having a translation key for the default language with the 
> sys_language_uid for every language as last part of the key. i.E.
> translation.key.0
>
> I would be eager to know, if there is clean way for handling this issue.
>
>
> Greetings
> Gion
>
Same here... I couldn't find an elegant solution. We get the "lang" from the session:


    $lang = $TSFE->getKey("ses", "lang");
    switch($lang) {
        case 0: tslib_eidtools::initLanguage('de'); break;
        case 1: tslib_eidtools::initLanguage('fr'); break;
        case 2: tslib_eidtools::initLanguage('it'); break;
        default: tslib_eidtools::initLanguage('de');
    }
    $GLOBALS['LANG']->includeLLFile(PATH_site .
'typo3conf/ext/hplusinfo/Resources/Private/Language/locallang.xml');

 $txt_more = $GLOBALS['LANG']->getLL('fe_search.showmore_txt')


Cheers,
Till
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list