-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Language locale values do not match web standards #2909
Comments
bad news are: the same was in 1.6.5... and it's taken from Google's documentation/recommendation. |
Can you provide a link to the google doc you mentioned? Case can be easily rectified by converting all to lowercase. |
unfortunately, could not find google's paper, but i found http://www.w3.org/International/questions/qa-lang-priorities.en.php and they are speaking only about '-', not '_'. so, for example:
... and in index.php something like that (for autatic detection): $detect = ''; if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && $request->server['HTTP_ACCEPT_LANGUAGE']) {
// it could be more than one language supported by browser/system. tested on linux (ru/en) |
there is no issues here. you can put what ever values you want to detect different languages. |
@danielkerr are you familiar with the If a given browser uses "en" and you simply add "en" to your query strings, you will not be able to successfully parse the response based on the fact that it could be:
Etc, etc... Are users expected to add a seemingly infinite number of possible numeric values after each language string in their system settings? I think you'll agree, this is unreasonable. While I agree it is not the responsibility of OpenCart to predict what languages will be used by a given site, at the very least, the |
The default language codes for English which are inserted on DB creation do not appear to follow web standards, and therefore will not find a match in many cases.
Case:
As of OpenCart 2.0.2.0 the database sets the following string for the English language locale:
en_US.UTF-8,en_US,en-gb,english
This is used to match against an array of languages produced from the browser's transmitted 'HTTP_ACCEPT_LANGUAGE'. In my case using Firefox v37 on OS X that string happens to be "en-US,en;q=0.5". Exploded this produces the array:
You can see the first element of the array follows standards described here: http://www.metamodpro.com/browser-language-codes setting the default language to "en-US'. The alternate would be 'en'.
In the first case it will not match our array since OpenCart uses '_' but browser transmits '-' as separator. IUn 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, in my testing, some browsers add space in the string so that exploded array elements could end up as ' en-US' which will cause additional difficulties matching.
My suggestion would be add or amend the locale field to include 'en-US' and possibly revise index.php to remove the relative quality factor string when creating the "browser languages" array like this:
Another solution would involve rewriting the language detection portion to use php's http_negotiate_language() function.
The text was updated successfully, but these errors were encountered: