Welcome Guest, Not a member yet? Register   Sign In
Change the language dynamically?
#1

I am attempting to change the system language dynamically with a call to a controller method. I have in the view :

PHP Code:
<?php if ($this->config->item('language') == "francais") : ?>
<a href="changelangue?lang=english" data-js-langue>EN</a> 
<?php elseif ($this->config->item('language') == "english"):?>
<a href="changelangue?lang=francais" data-js-langue>FR</a>
<?php endif;?>

And in the controller I have this method:

PHP Code:
public function changeLangue(){

    if (!isset(
$_GET['lang']))
    {
        
redirect("vehicules");
    }

    
$this->config->set_item('language'$this->input->get('lang'));
    
redirect("vehicules");


I am being redirected, but the config language is not changing. It seems to always revert to the default language. I even tried changing it in the ' __construct' of the controller in question using the session userdata like so:

PHP Code:
public function __construct()
{
    
parent::__construct();
    if (!
$this->session->userdata('language'))
    {
        
$this->session->set_userdata('language'$this->config->item('language'));
    }else{
        
$this->config->set_item("language"$this->session->userdata('language'));
    }


I have the language folders in system/language and in language.

Am I missing something?
Reply


Messages In This Thread
Change the language dynamically? - by goobydale - 04-22-2021, 12:15 PM
RE: Change the language dynamically? - by paliz - 04-23-2021, 09:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB