Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug with locale.language

 

When you call locale.language it returns the value in the format "en_AU" instead of "en-AU". I tested this for "fr-FR", and "de-DE" and it returned these in the incorrect format. I presume that this is the case for other locales.

As these are not using the international standard (BCP: 47) of "dd-DD", you cannot perform functions such as date.toLocaleString(locale) as it returns as the error "error: RangeError: Invalid language tag: en_AU".

According to BCP: 47, 

A language tag is composed from a sequence of one or more "subtags",
   each of which refines or narrows the range of language identified by
   the overall tag.  Subtags, in turn, are a sequence of alphanumeric
   characters (letters and digits), distinguished and separated from
   other subtags in a tag by a hyphen ("-", [Unicode] U+002D).
Best Answer
4 REPLIES 4

I totally agree.

 

The thing is, according to the official docs, the code "should" be in the BCP 47 format (https://dev.fitbit.com/build/reference/companion-api/user-settings/).

Best Answer
0 Votes

I've logged this one, but I'm not sure if it's a documentation issue, or a bug at this time. Will let you know. Thanks!

Best Answer

Also the Fitbit Web API uses the wrong localisation:

https://dev.fitbit.com/build/reference/web-api/basics/

This will ignore the specification for the Accpept-language header: 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language

which will refer to this spec:

https://tools.ietf.org/html/rfc7231#section-3.1.3.1

 

So this seems to have a deep impact in all APIs.

Best Answer
0 Votes

@allyannI found this in my clock face app when creating localised versions of the settings page and had to write a routine to replace the underscores with hyphens. Strangely, the local is returned in the correct format on the watch, just not in the companion app. Hope this helps.

Best Answer
0 Votes