I have a PHP Language autodetect feature that loads a different page according to the browser's language.
The code works fine when I try to bypass the browser's language (using a browser extension), but it won't work properly when I try to append a country.
This is my code, where I want to load a version for Canada (CA) and a different one for France (FR):
<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
case "en":
include("translations/en.php");
break;
case "fr_CA":
include("translations/fr-CA.php");
break;
case "fr_FR":
include("translations/fr-FR.php");
break;
default:
include("translations/en.php");
break;
}
?>
Tried also adding and if
within case "fr":
introducing the locales, but it won't work either.