Search code examples
phphtmljoomla

Change some words to other language in module in Joomla 3.x


I have a sidebar on website which is designed on Joomla. This sidebar is a module and it works properly, but I would like to change language of some words in this module. How can I do this in Joomla or in my files? Now this sidebar is in Polish and I'd like to change into English. In Joomla I have turn on these two language. On polish menu it should be polish as it is now, but when I'll change it into english menu I'd like to this sidebar show english words.

Thank you for help!


Solution

  • Here is an example:

    $lang = JFactory::getLanguage();
    $extension = 'com_helloworld';
    $base_dir = JPATH_SITE;
    $language_tag = 'en-GB';
    $reload = true;
    $lang->load($extension, $base_dir, $language_tag, $reload);
    

    Following is an explanation of the variables

    1. $extension - This is the extension whose language file will be loaded
    2. $base_dir - Should be JPATH_SITE in case you have language files stored elsewhere. Defaults to JPATH_BASE. [optional]
    3. $language_tag - This is the locale string. Language files for this locale will be loaded. Defaults to the one set in backend. [optional]
    4. $reload - Flag that will force a language to be reloaded if set to true. [optional]