Change the language dynamically? |
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?
Working With Locales
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(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().
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')});
Enlightenment Is Freedom
For CodeIgniter 3 read this one.
Enable Multi Language Capability in CodeIgniter What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |