Welcome Guest, Not a member yet? Register   Sign In
Overwrite when loading a different language?
#1

[eluser]mDonchev[/eluser]
Hello,

I have multilingual website and I'm trying to load one or another language strings.

I've made a language file and I put it in the "english" folder. It works fine.
But when I try to load the other language like this:
Code:
//Loading the language file
switch($_new_language) {
   case "en": $this->lang->load('texts', 'english'); break;
   case "bg": $this->lang->load('texts', 'bulgarian'); break;
}

The other language (bulgarian in my case) is not loaded and the english text strings are still available.

Please tell me if I should "unload" the old language or do something else before I load the new language?

THanks
Martin
#2

[eluser]mantis[/eluser]
I have the same problem. This is my issue:

- Don't use autoload language in autoload.php: $autoload['config'] = array();
- In every controller you must call $this->lang->load('file_language', 'your_language');
#3

[eluser]maesk[/eluser]
No need to unload the "old" language. As mantis said, maybe autoload.php could be the problem. Another problem could be that your $_new_language isn't actually set to "bg".

From the user guide:
Quote:
Code:
$this->lang->load('filename', 'language');
Where filename is the name of the file you wish to load (without the file extension), and language is the language set containing it (ie, english). If the second parameter is missing, the default language set in your application/config/config.php file will be used.

So your Bulgarian text file has to be in a folder called 'bulgarian' the way you load it, otherwise CI will not find it and load the default English.

You could also store your language files like this:
system/application/language/en/texts_lang.php
system/application/language/bg/texts_lang.php

and then load it like this:
Code:
//Loading the language file
$this->lang->load('texts', $_new_language);
}

No need for a switch statement.




Theme © iAndrew 2016 - Forum software by © MyBB