A straightforward way to translate your language files in CodeIgniter
Months ago we discussed about different alternatives to add i18n support to CodeIgniter applications. On this opportunity we will show how easy is to maintain your language files using CodeIgniter Language File Translator by MrKirkland and Owen Christian.
Basically what you need to do is download the zip here and then unpack the files under appropriate location, as explained in the article.
Afterward, create your desired language files languages folder. For example, if you would like to use English and Spanish, let’s say you create these two files:
- application/languages/spanish/general_lang.php
- application/languages/english/general_lang.php
You’d need to load that general language file in your controller or the autoload.php config file, and then choose which of these files you will use as Master file. That means the file that you will keep updated every time and use as reference when synchronizing with the other slaves files.
Then, you’ll need to run the new controller that was unpacked by pointing your browser to index.php/translator
You will be guided through the translator interface that will take care of your language strings under master and slave files. So, go to your slave files and translate each value.
In case any key in your slave file is not present under your master file, then you will see a mismatch error message warning about that behavior.
For non-english speakers: If you plan to use a different Master file rather than English, you can. In theory you’d need to edit the config file under /application/config/translator.php , but my last attempt did not work in version 0.5.1, For example, if I’d like to use Spanish as Master language instead of English, then I needed to edit the variable used in controllers/translator.php under line #87:
var $masterLang = 'spanish';
For more information, we strongly recommend to read the author’s article.



