• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change language globally

#1
[eluser]Sander Versluys[/eluser]
How to change the language globally for your codeigniter application?

Setting it like following doesn't work:

Code:
$this->config->set_item('language', 'nl');

The language files are present, i've changed the the full names to shorter ones. When i set the config file manually, it works.

#2
[eluser]xwero[/eluser]
Code:
function MY_Language()
    {
        parent::CI_Language();
    }
    /**
    * Makes switching between languages easier
    *
    *  example : http://ellislab.com/forums/viewreply/339962/
    */
    function switch_to($idiom)
    {
        $CI =& get_instance();
        if(is_string($idiom) && $idiom != $CI->config->item('language'))
        {
            $CI->config->set_item('language',$idiom);
            $loaded = $this->is_loaded;
            $this->is_loaded = array();
                
            foreach($loaded as $file)
            {
                $this->load(str_replace('_lang.php','',$file));    
            }
        }
    }
Something i added to the wiki many moons ago, this gets you started i think Wink

#3
[eluser]Sander Versluys[/eluser]
Thanks... good stuff, exactly what i needed!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.