Welcome Guest, Not a member yet? Register   Sign In
librarie: multi_language
#2

[eluser]Unknown[/eluser]
a second method to make an multi-language ci is to modified the loader-class

Replace the Constructor of the loader-class
Code:
system/libraries/loader.php

with these code
Code:
/**
     * Constructor
     *
     * Sets the path to the view files and gets the initial output buffering level
     *
     * @access    public
     */
    function CI_Loader()
    {    
        $this->_ci_is_php5 = (floor(phpversion()) >= 5) ? TRUE : FALSE;
        
        $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
        $lange = explode(';', $lang);
        $lange2 = explode('-', $lange[0]);
        $lang = $lange2[0];
        
        $view_path = APPPATH.'views/' . $lang . '/';
        
        if(is_dir($view_path))
        {
            $this->_ci_view_path = $view_path;
        }else{
            $this->_ci_view_path = APPPATH.'views/en/';
        }        
        
        
        $this->_ci_ob_level  = ob_get_level();
                
        log_message('debug', "Loader Class Initialized");
    }

and implement the controller like this:
Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();
    }
    
    function index()
    {
        $this->load->view('welcome');
    }
}

?>
Wink


Messages In This Thread
librarie: multi_language - by El Forum - 07-13-2007, 03:32 AM
librarie: multi_language - by El Forum - 07-13-2007, 03:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB