This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21289 - Notification of change to navigator.language (locale change)
Summary: Notification of change to navigator.language (locale change)
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC All
: P3 enhancement
Target Milestone: Needs Impl Interest
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
: 22242 (view as bug list)
Depends on:
Blocks: 21290
  Show dependency treegraph
 
Reported: 2013-03-14 19:36 UTC by Marcos Caceres
Modified: 2014-09-29 23:36 UTC (History)
7 users (show)

See Also:


Attachments

Description Marcos Caceres 2013-03-14 19:36:52 UTC
Users sometimes need to switch locale settings on their device. When this happens, the value of navigator.language is changed (or should be!). It would be nice if HTML provided some means to be notified that the change had taken place. 

The application can then use this information to perform appropriate localization changes on the client side. For example, reformatting DOM elements that contain times and dates to better suit the new locale information (this could work together with the  ECMAScript i18n API).
Comment 1 Marcos Caceres 2013-03-14 19:40:58 UTC
See also: http://lists.w3.org/Archives/Public/public-sysapps/2013Mar/0097.html

FireFox OS has a mutation observer that watches for changes in "language.current" of "navigator.mozSettings":

navigator.mozSettings.addObserver('language.current', function(event) { … });

Blackberry also has an event for this:
http://developer.blackberry.com/html5/api/blackberry.system.html#.event:languagechanged
Comment 2 Mounir Lamouri 2013-03-15 22:59:42 UTC
There were some ideas to push a Web l10n specification that would add a 'locale-change' event (or something similar) fired to the document object. I am not sure how such a specification would be followed though.
Comment 3 Mounir Lamouri 2013-03-25 18:27:55 UTC
For the record, Firefox OS is using this: https://github.com/fabi1cazenave/webL10n
Comment 4 Ian 'Hixie' Hickson 2013-04-29 23:40:36 UTC
This would be easy to spec if anyone wants to implement it.

Who wants to implement it?

See also bug 17859.
Comment 5 Marcos Caceres 2013-04-30 10:26:19 UTC
Mozilla has expressed interest in implementing.
Comment 6 Mounir Lamouri 2013-04-30 14:46:15 UTC
Yes, we are interested, at least in an application context (like Firefox OS) where such a feature would be very useful.
Comment 7 Olli Pettay 2013-06-03 09:32:22 UTC
*** Bug 22242 has been marked as a duplicate of this bug. ***
Comment 8 Ian 'Hixie' Hickson 2014-07-21 20:57:47 UTC
There's a "languagechange" event that fires at Window when navigator.languages change.

Language and locale are different, but since currently we don't expose any locale stuff, it might be a moot point...
Comment 9 Ian 'Hixie' Hickson 2014-09-29 23:36:11 UTC
I'm marking this WORKSFORME since the actual request has been done. I'm sure if we add locale stuff that we'll add locale change notifications as part of it.