Setting Language based on Domain
Posted: Wed Dec 07, 2016 11:39 pm
Hej guys,
I would like to set the customers language based on the current domain (I have modded my OC so that form one core I got 2 languages running on separate domains). Unfortunately I am a php noob. My solution would be to attach ?language=de or ?language=en to the customers landing page via JS. Not a good one.
In the startup php it says:
How could I change this code so that it does IF current domain = domainA.de set "de" IF current domain = domainB.com set "en".
Ideas anyone? I'd really appreciate it!
Thanks!
I would like to set the customers language based on the current domain (I have modded my OC so that form one core I got 2 languages running on separate domains). Unfortunately I am a php noob. My solution would be to attach ?language=de or ?language=en to the customers landing page via JS. Not a good one.
In the startup php it says:
Code: Select all
// Language Detection
if (!empty($this->request->server['HTTP_ACCEPT_LANGUAGE']) && !array_key_exists($code, $languages)) {
$detect = '';
$browser_languages = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']);
// Try using local to detect the language
foreach ($browser_languages as $browser_language) {
foreach ($languages as $key => $value) {
if ($value['status']) {
$locale = explode(',', $value['locale']);
if (in_array($browser_language, $locale)) {
$detect = $key;
break 2;
}
}
}
}
if (!$detect) {
// Try using language folder to detect the language
foreach ($browser_languages as $browser_language) {
if (array_key_exists(strtolower($browser_language), $languages)) {
$detect = strtolower($browser_language);
break;
}
}
}
$code = $detect ? $detect : '';
}
Ideas anyone? I'd really appreciate it!
Thanks!