2

Setting: 7 System Lanaguages An editor page which is entirely German (no language switcher). However part of the page is a preview screen where the editor ought to see the edited content already translated into the respective System Language.

Is there a way I can give JText::_('TRANSLATE_STRING') a parameter which determines the target language of the translation?

Is there another function which gives easy access to the translation?

Or can I change the current language of the Session programatically?

I am a little lost on the documentations I find online and stuck without the right ideas or terms to research.

user3154108
  • 1,264
  • 13
  • 23

1 Answers1

2

JFactory::getLanguage() will get you the current language object (JLanguage instance).

JLanguage::getInstance($lang) can get you the language instance you want. You'll need to specify the language code as parameter. You can then use the instance to translate language resources.

For example:

$lang = JLanguage::getInstance('de-DE');
echo $lang->_('TRANSLATE_STRING');

Would output the german version of 'TRANSLATE_STRING'

Eric Maziade
  • 306
  • 1
  • 4