Most effective way working with multiple natural languages Most effective way working with multiple natural languages codeigniter codeigniter

Most effective way working with multiple natural languages


I've never used CI_Language but it appears to use language arrays to do the translation.

Overly simplified example of this type method:

$trans = array(    'MAIN_TITLE' => 'Title Here');echo $trans['MAIN_TITLE'];

Personally I find this really annoying because you're then editing views that are cluttered with array key names instead of useful text. Which can be quite annoying at times. Not to mention you have to remember which keys correlate to which strings if you are using them in multiple places.

I use Gettext which I find much easier. You just have to wrap your strings with the translate method: _(). Then once you're done with your app, you open up PoEdit and create the new language file. PoEdit will parse all of my source files looking for strings wrapped like this <?php echo _('Title here') ?> and insert them into the .po language file. You can then go string by string and translate the text easily within PoEdit. The benefit of this is you have the source translation right there within PoEdit, instead of a meaningless array key name in some include file

This all makes my life much easier in that I can update my language files every Friday with one click. Any new or modified translations will automatically be added to my language file, and any unused translations will automatically be removed. I send the files off to my 3 international branchs for translation, and my changes and updated language files are ready to be deployed Monday morning


You may want to have a look into php intl library. http://php.net/intl