Change the language dynamically? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Change the language dynamically? (/showthread.php?tid=79120) |
Change the language dynamically? - goobydale - 04-22-2021 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") : ?> And in the controller I have this method: PHP Code: public function changeLangue(){ 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() I have the language folders in system/language and in language. Am I missing something? RE: Change the language dynamically? - InsiteFX - 04-22-2021 Working With Locales RE: Change the language dynamically? - goobydale - 04-23-2021 (04-22-2021, 08:40 PM)InsiteFX Wrote: Working With LocalesHey thanks for your answer! I should have mentioned I am on 3.1.11. Unless someone officially rebukes it, there's no way to set the language in the config with it having a default value set up and redirecting from with redirect(). RE: Change the language dynamically? - paliz - 04-23-2021 go app/config/app.php chane like bellow PHP Code: public $defaultLocale = 'en'; for change language add header Accept-Language = En or .... you can see i add header for angular code request.clone({headers: request.headers.set('Accept-Language', 'en')}); RE: Change the language dynamically? - InsiteFX - 04-23-2021 For CodeIgniter 3 read this one. Enable Multi Language Capability in CodeIgniter |