Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#18722 closed defect (fixed)

Dojo can read incorrect locale value from Chrome

Reported by: a06275 Owned by: bill
Priority: undecided Milestone: 1.10.5
Component: Loader Version: 1.10.4
Keywords: Cc:
Blocked By: Blocking:

Description

Using Dojo heavily in an enterprise web-app, I am having problems with Date formatting that I've traced back to the locale specified in dojo.config. Specifically, I'm getting a locale of "en-us" rather than the correct "en-gb". Having dug further, I've discovered the cause of this.

In dojo/_base/config, the user's locale can be read from the browser using the navigator object. Specifically, it tests for ...

navigator.language || navigator.userLanguage

... however the language property in Chrome is actually set to the download locale, so English users will often download with a locale of en-US and hence Dojo loads into this locale rather than the preferences set by the user in their browser settings.

There is a blog post at https://alicoding.com/detect-browser-language-preference-in-firefox-and-chrome-using-javascript/ regarding this problem, and the suggested solution is to use another property found on the Chrome navigator object, specifically languages, which has a prioritised list of the user's chosen languages. The better test would therefore be ...

navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage)  

... which would solve the problem of Dojo loading into the wrong locale.

Change History (7)

comment:1 Changed 4 years ago by a06275

comment:2 Changed 4 years ago by bill

Milestone: tbd1.10.5
Owner: changed from Rawld Gill to bill
Status: newassigned

comment:3 Changed 4 years ago by bill

Resolution: fixed
Status: assignedclosed

Pushed in 31977b8870a1b3b3a618578450e63d211f594fdc and 31977b8870a1b3b3a618578450e63d211f594fdc.

comment:4 Changed 4 years ago by bill

Hmm, this change broke Android 6.0 (or at least in the emulator). Since we've already technically released 1.11.0 I filed #18818 to fix the regression.

comment:5 Changed 4 years ago by Bill Keese <bill@…>

In 48bd17d/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:6 Changed 4 years ago by Bill Keese <bill@…>

In 5db6bd6/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:7 Changed 4 years ago by Dylan Schiemann <dylan@…>

In 3594395/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 
Note: See TracTickets for help on using tickets.