I want to set a cookie whenever a user visits a page, so not only the home page but also people that find the site through google.
On every page I need to check wheter or not the user has a cookie set with his language.
If no cookie i set make one if there is one, don’t do anything.
Can I make a function that I can load on every page? If so, how?
I’m using the codeIgniter framework with i18n 2.1 for multi language.
I also have a second question:
I’m using i18n for multi language. I’ve set nl as the first language in the array:
private $languages = array(
'nl' => 'dutch',
'en' => 'english',
'de' => 'german',
'fr' => 'french'
);
but everytime you visit my base url, en, english, is loaded. Am I missing something?
Edit: I just can’t seem to get the correct language to load. the cookie is set to dutch but when I go to the base url and check what cookies is loaded it just ignores the cookie and loads the english home page.
For your first question:
To make a function that runs on every page you need to extend the base Controller class. Pretty good instructions are here:
http://codeigniter.com/wiki/MY_Controller_-_how_to_extend_the_CI_Controller
You will make a file called MY_controller.php and put in in /application/core/.
Then inside the constructor method of the extension you can call functions that will run on every page.
I am not sure about your second question. I have always just built language systems separately and let the users choose their language.