Welcome Guest, Not a member yet? Register   Sign In
Localization / Translation how to load English as base and then other Language
#1

[eluser]ruiganga[/eluser]
Hi

I am saving in sessions the language that users will see the app.

I want to offer multiple languages, but my problem is to be able to provide all the language updates while I am developing.

The solution I used without CI was to load a language file, says for english, and then load the french file.

That way, the first load will have all the sentences translated, the second load would override the first.

If I have some translation in english that I don't have in french, the app still display it in english.

I can't do this with codeigniter. It only keeps the first loaded language file.

Any tip for me?

Thanks
#2

[eluser]pickupman[/eluser]
Looking at the [url="https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Lang.php#L77"]Language loader[/url] in the CI 3.0dev branch, which you probably should be using, should already handle this. See the available parameters to the load function.
Code:
/**
* Load a language file
*
* @param mixed $langfile Language file name
* @param string $idiom Language name (english, etc.)
* @param bool $return Whether to return the loaded array of translations
* @param bool $add_suffix Whether to add suffix to $langfile
* @param string $alt_path Alternative path to look for the language file
*
* @return void|string[] Array containing translations, if $return is set to TRUE
*/
function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') {

}

By passing 5th parameter to the users language file should over write the english class.




Theme © iAndrew 2016 - Forum software by © MyBB