Codeigniter Change Uploaded Language

I currently have a language loaded inside MY_Controller that extends CI_Controller. But inside the special page, which controller (let it be called the ABC controller) extends MY_Controller, I need to redefine the loaded language with another language. I tried loading a different language inside this ABC controller, but to no avail. Is there a way to unload a downloaded language and load another language?

+5
source share
5 answers

Have you tried just downloading the language file that you need?

$this->lang->load('filename', 'language');

Then it should be available in the same way as your default language. I have not tested this, but in my opinion, this should be the way to do it.

: http://codeigniter.com/user_guide/libraries/language.html


REVISED

, ( ), - .

:

  • , ( ), .
  • ANOTHER , , ( constructor - / .
  • 2 (1 , .. !)

: http://codeigniter.com/forums/viewthread/176223/

+3

reset is_loaded

$this->lang->is_loaded = array();
$this->lang->language = array();
+17

.

$this->lang->load('text', 'english');
echo $this->lang->line('__YOUR_LANG_VARIABLE__');

//CI will record your lang file is loaded, unset it and then you will able to load another
//unset the lang file to allow the loading of another file
if(isset($this->lang->is_loaded)){
    for($i=0; $i<=sizeof($this->lang->is_loaded); $i++){
        unset($this->lang->is_loaded[$i]);
    }
}

$this->lang->load('text', 'chinese');
echo $this->lang->line('__YOUR_LANG_VARIABLE__');

, .

+4

, , , "config" .

$this->config->set_item('language', 'chinese');
$this->config->set_item('language', 'english'); // based on the language folder of course holding language files

lang, , , .

+4

- , codeigniter, , :

  •  
  • application/language/arabic( sma2, ci)  
  • setting.php 
application/modules/settings/views/setting.php :
<div class="controls">

    <?php /*

  $lang = array (
      'english' => 'English',

      'arabic' => 'Arabic',  // +++ Add this line

      'spanish' => 'Español'

.

-1

All Articles