I tried a lot but I have 2 problems which I can't find a solution for them:
1. I don't know how to set the default language programmatically
2. How to detect if the website / page loads for the first time
Here is the code I tried:
Code: Select all
$supportedLangs = array('en', 'ru', 'ar', 'fa', 'tr');
$languages = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach($languages as $lang)
{
$lan = explode(';',$lang);
if (strlen($lan[0]) <= 2) {
if(in_array($lan[0], $supportedLangs))
{
$this->language->set($lan[0]);
break;
}
}
}