Change language runtime |
Hi
On my shop website, I need to change shop language auto with user IP For example, if a user is from Turkey, so load Turkey language or English language for America I load English language default I try to change the language in the config file but I cannot use the $this->db command and got error I have country IPs in database and use query for detect user country with ip And that is important check IP before set $config['language'] parameter Thanks
(11-21-2021, 09:09 PM)hxd Wrote: Please read this docs That is Codeigniter 4 and I'm still on Codeigniter 3 My question is change language runtime
Well, since you already have a way of detecting a user's country, I believe you are already close to what you are looking for.
From the docs, you will need to store the particular language of a user in the session. So, you can use that to automatically display the current page/language to the user. PHP Code: $idiom = $this->session->get_userdata('language'); (11-21-2021, 08:43 AM)omid_student Wrote: Hi (11-21-2021, 09:09 PM)hxd Wrote: Please read this docsthanks a lot! (11-21-2021, 09:09 PM)hxd Wrote: Please read this docs Thanks alot Sir!
Here is how to get it with php.
How to detect Browser Language in PHP? Make sure you do not have any security issues in your method with this code. 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 |