Ixonn Group

Module Language

You are here:
< All Topics

Each module can have separate language files to prevent messing up with the system language files.

To add language files to your module so users can translate it, you must create a folder in modules/[module_name]/language/[language_name_folder]

At this time the [language_name_folder] must exist in the core language files located in application/language

For example, if you want to create English language translations, you will create the following folder(s): /modules/[module_name]/language/english

Language Files

In each language, you can create unlimited number of files e.q. if you want to separate specific features language files or you can include them in one general language file.

The file name must end with _lang.php, you should check the Codeigniter framework documentation for more info about the language file name and it’s usage.

In this example we will create sample_module_lang.php file in /modules/[module_name]/language/english/

For each additional language you want to have translations, you must include all files from your general language e.q. in this case English

For example, if you have 3 language files in the /english folder and you want to include new Spanish language, you must create new folder for the Spanish language and copy those 3 language files in the /spanish folder.

Registering Language Files

Instead of loading the language files directly there is a helper function to register the language files and allow your language to support using a custom_lang.php file so the end users can overwrite the translations.

More info about custom_lang.php file in the language directory can be found here

In your module init file add the following code:

register_language_files(‘module_name’, [‘sample_module’]);

The first parameter to the register_language_files function is the module name, don’t forget to replace module_name with your actual module name.

The second parameter must be an array with language files names without the _lang.php.

Fetching a Line of Text

Instead of using the Codeigniter framework default method to fetch translation line of text, you can use Ixonn custom function:


 * @param  string $line   language line key

 * @param  mixed $label   label e.q. if you have $lang[‘sample_module_create_new’] = ‘Create New %s’;

 * @return string         language text


_l($line, $label = ”, $log_errors = true);

Related Articles

Table of Contents
Scroll Up