Welcome Guest, Not a member yet? Register   Sign In
problem changing the language
#3

[eluser]tomcode[/eluser]
You cannot change the language after You have loaded language files, only before.

I. You can fetch a language file and keep the values in a variable, but only for language files You do not have already loaded.

This works :
Code:
$lang = $this->lang->load('filename', 'language', true);
// change language
// ..
$this->lang->load('filename', 'language');

This not :
Code:
$this->lang->load('filename', 'language');
// change language
// ..
$lang = $this->lang->load('filename', 'language', true);



II. I've written an extension to switch the language, it reloads all previous loaded language files

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Language extends CI_Language {

    var $language   = array();
    var $is_loaded  = array();

    /**
     * Resets the class variables
     *
     * @access  public
     * @param   void
     * @return  void
     */
    function reset()
    {
        $this->language = array();
        $this->is_loaded = array();
    }

    // --------------------------------------------------------------------

    /**
     * Reloads all currently loaded language files
     *
     * @access  public
     * @param   void
     * @return  void
     */
    function reload()
    {
        log_message('debug', 'MY_Language reloading all language files');
        
        $is_loaded = $this->is_loaded;
        
        $this->reset();
        
        foreach($is_loaded as $langfile)
        {
            $this->load($langfile);
        }
    }

}


Messages In This Thread
problem changing the language - by El Forum - 08-30-2010, 11:15 AM
problem changing the language - by El Forum - 08-30-2010, 12:11 PM
problem changing the language - by El Forum - 08-30-2010, 04:08 PM
problem changing the language - by El Forum - 08-31-2010, 04:57 AM
problem changing the language - by El Forum - 08-31-2010, 01:20 PM
problem changing the language - by El Forum - 08-31-2010, 04:03 PM
problem changing the language - by El Forum - 09-01-2010, 06:26 AM
problem changing the language - by El Forum - 09-01-2010, 08:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB