[TYPO3-mvc] extbase - translate label for other language

Viktor Livakivskyi invisible.kinder at gmail.com
Wed Feb 5 17:53:59 CET 2014


Hi, Krystian.

> What do you mean by "re-init LocalizationUtility"?
> All methods there are protected except ::translate.
> 
> and there is early return in initializeLocalization() after first use of 
> ::translate
> 
> static protected function initializeLocalization($extensionName) {
> 		if (isset(self::$LOCAL_LANG[$extensionName])) {
> 			return;
> 		}
> 
> So changing $GLOBALS['TSFE']->config['config']['language'] gives no effect.
> 
> I already tried this.

Yes, you're right. I've looked again into Extbase's LocalizationUtility and our old project sources. We did it different - we didn't store current language (it was an idea, taht's why I remember it) - we used early hook to change website's language from selected by user to the one, that is set in hid profile. So it is different situation.

And talking about your case, I can see only dirty method: using reflection, make $LOCAL_LANG and $languageKey properties accessible, unset $LOCAL_LANG[$extensionName] and set $languageKey  to your desired language - so initializeLocalization() method will re-inint labels. And then put it all back.
But, I really hope, that there is much cleaner solution, because for me it looks now as "hack the hack".


More information about the TYPO3-project-typo3v4mvc mailing list