Variables question |
Hi to everybody! I need to change the 'defaultLocale' var from a controller, in codeigniter 3 I could do that simply with this line:
$this->config->set_item('language', $lang); But in Codeigniter4 if try to do this: config('Config\\App')->defaultLocale = $lang; The value of the global config don't change... How can i do this? With the function config() i'm accessing to the global config or to a new instance of config? Thx!
What do you want to do exactly?
You should not change the defaultLocale, because it is the system default locale. See https://codeigniter4.github.io/CodeIgnit...on-classes
This tutorial will give you an idea of how its done in CodeIgniter 4, and it works.
IncludeBeer - Creating a multilingual website with CodeIgniter 4 (part 1) IncludeBeer - Creating a multilingual website with CodeIgniter 4 (part 2) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-18-2024, 08:05 PM)Huisache Wrote: Hi to everybody! I need to change the 'defaultLocale' var from a controller, in codeigniter 3 I could do that simply with this line: The best move would be to add the CodeIgniter Settings official package to your application (https://settings.codeigniter.com/), then you can easily change defaultLocale like this: PHP Code: service('settings')->set('App.defaultLocale ', 'fr'); |
Welcome Guest, Not a member yet? Register Sign In |