Loading extra language files

From Joomla! Documentation

Revision as of 08:36, 26 July 2010 by Coolbung (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Many times, you need to load extra language files in your code. An example is loading your component's language file into a module for that component. Following is the code that helps you do this

PHP Code

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

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_SITE [optional]

3. $language - This is the locale string. Language files for this locale will be loaded. Defaults to the one set in backend. [optional]