Sandy Fark
Sandy Fark

Reputation: 173

Multi language with codeigniter

I am working on a project based on codeigniter. I can set languages by this

$this->lang->load('file', 'french');
$this->lang->load('file', 'german');

Now my question is how can I detect which language file to load? For example if I will load language after detecting ip or browser and if user from england went to france and opening website from a cafe then he will see website in french language..

How can I achive this? Is anyone have idea?

Upvotes: 1

Views: 949

Answers (3)

oleurud
oleurud

Reputation: 88

Codeigniter save the files of default language at the start in the session array. The solution is reload this array with the new language files.

I make a small package which implement this solution easily https://github.com/oleurud/Codeigniter_Multi-language_Package

Upvotes: 0

vikas
vikas

Reputation: 735

User will choose which language he wants to see in this website. He will choose it from the drop down or something else then you will store the same in the cookies/session and hence can show the chosen language file.

Also using ips is a little hangy in exceptional cases like corporate networks.

Upvotes: 0

noob
noob

Reputation: 9212

$_SERVER['HTTP_ACCEPT_LANGUAGE'] is the language (for example en or fr)

Upvotes: 1

Related Questions