Open
Bug 1141966
Opened 11 years ago
Updated 11 years ago
Language variant codes (such as ca-ES@valencia) aren't handled.
Categories
(L20n :: JS Library, defect)
Tracking
(Not tracked)
UNCONFIRMED
People
(Reporter: autopulated, Unassigned)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.22 Safari/537.36
Steps to reproduce:
We're using the l20n javascript bindings, and have visitors with language tags like "ca-ES@valencia" in their navigator.languages array.
(Note that we use navigator.languages, if the browser supports it, which is not the default l20n behaviour – so as a workaround we are now filtering out these locales in our own code.)
Code to reproduce:
var languages = navigator.languages;
if(languages && languages.length){
ctx.requestLocales.apply(ctx, languages);
}else{
ctx.requestLocales(navigator.language || navigator.browserLanguage);
}
Typical user-agent:
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:25.0) Gecko/20100101 Firefox/25.0
Actual results:
An exception is raised – errors like this are showing up in our client-side error reporting:
"invalid language tag:ca-ES@valencia, parsing requested locales: [\"ca-ES@valencia\"]"
Expected results:
These tags should either be handled completely (ideal), be ignored, or fall-back to the non-variant version of the tag. In any case an exception should not be raised.
Comment 1•11 years ago
|
||
I know nothing about how L20n works, but I'm just popping by to confirm that 'ca-ES@valencia' is not a valid language tag and should not be parsed as one.
The correct language tag is 'ca-valencia' or, if truly necessary, 'ca-ES-valencia'.
Comment 2•11 years ago
|
||
Thanks, Gordon. I was going to comment to saythe same thing.
The 1.0.x branch of L20n which this bug is about uses the ECMA 402 specification for handling language codes and language negotiation, with a small addition of non-standard prioritizeLocales method:
https://github.com/l20n/l20n.js/blob/65f0c478335bc29d17de244ffcf1269c089ed439/lib/l20n/intl.js
http://wiki.ecmascript.org/doku.php?id=globalization:prioritizelocales
While the tag is invalid, throwing an exception is probably a little bit too brutal.
You need to log in
before you can comment on or make changes to this bug.
Description
•