Re: Manifest internationalization Model

On Wednesday, 13 March 2013 at 07:46, Ming Jin wrote:

> > > The former might require to reload the localized html page upon language
> >  
> > change, while the latter provides an opportunity for doing localization
> > without reloading (with the help of "language change" event and i18n API,
> > or sort of).
> >  
> > I'd based my research on the following sources, but I can't find any
> > mention of the event:
> > https://developer.chrome.com/extensions/i18n.html
> > https://developers.google.com/chrome/web-store/docs/i18n
> >  
> > Do you have a pointer to the even?
>  
> I cannot find either. It's just my wish to have such an event. FxOS seems to have an event called "localized" [1].
>  
> [1] https://github.com/fabi1cazenave/webL10n  
>  


I see. That ("localized") one is a little bit different, as it's bound to that particular localisation library and only fires as a result of localising the content of the page (i.e., once the DOM is traversed and strings are replaced where appropriate).  

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

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

See:  
https://github.com/mozilla-b2g/gaia/blob/master/shared/js/l10n.js#L958

There is also the possibility to do this with the Settings API (this currently seems buggy in FxOS - returns the wrong result, but the event fires nonetheless):

navigator.mozSettings.onsettingchange = function(e){console.log(e)}

In theory, that should return a SettingChangedEvent with settingName "???.locale" and settingValue: "lang-TAG".

Anyway, there are a few possibilities here.  

--  
Marcos Caceres
http://datadriven.com.au

Received on Wednesday, 13 March 2013 10:02:13 UTC