Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

i18n language

$
0
0
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?

Viewing all articles
Browse latest Browse all 14343

Trending Articles