Case:
As of OpenCart 2.0.2.0 the database sets the following string for the English language locale:
Code: Select all
en_US.UTF-8,en_US,en-gb,english
Code: Select all
array(
[0] => 'en-US'
[1] => 'en;q=0.5'
)
In the first case it will not match our array since OpenCart uses '_' (underscore) but browser transmits '-' (dash) as separator. In the second it could match but for the relative quality factor string following en. So in either case we will not find a match.
Additionally, some browsers add space in the string so that exploded array elements could end up as ' en-US' which will also fail to match anything unless the additional whitespace is trimmed.
My suggestion would be add or amend the locale field to include 'en-US' and 'en' and also revise index.php to format the $browser_languages array. We should remove the relative quality factor string and trim whitespace - maybe like so:
Code: Select all
$browser_languages = preg_replace(array('/;.*/','/\s/'),'',$browser_languages);