CodeIgniter Forums
i18n language - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: i18n language (/showthread.php?tid=69248)



i18n language - ponzo - 10-26-2017

I'm building a multilangual app with both CI views, as Vuejs views. Therefore I switched to i18n json translations.
Very easy and accessible for both, since i can share the same language files 

lang_de.json, lang_en.json etc

I added the php-i18n to my autload.php, so it's loaded as a library
With this i18n-editor i can easily create files to translate within different languages.


Code:
{
    "greeting": "Hello World!",
    "category": {
        "somethingother": "Something other..."
    }
}


In controller:
$this->i18n->setFilePath(APPPATH.'/lang/lang_de.json'); 
this->i18n->init();

In view:
<?php echo L::greeting;?>


What would be the best place to set : setFilePath to a language, and change when another language would be selected.
Would this be a hook?