Closed Bug 1013929 Opened 11 years ago Closed 10 years ago

Use the languagechange event instead of a mozSettings observer

Categories

(Firefox OS Graveyard :: Gaia::L10n, defect)

All
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Assigned: zbraniecki)

References

()

Details

Attachments

(2 files)

With bug 889335 fixed, we can stop listening to mozSettings' changes to language.current and use the new window.onlanguagechange event.
Attached patch patch (deleted) — Splinter Review
What do you think Stas?
Assignee: nobody → gandalf
Status: NEW → ASSIGNED
Attachment #8426696 - Flags: feedback?(stas)
Comment on attachment 8426696 [details] [diff] [review] patch Review of attachment 8426696 [details] [diff] [review]: ----------------------------------------------------------------- I thought the patch would look exactly like this, but upon testing it turned out that the languagechange event was emitted twice: the first time navigator.language was en-US, and the second time it had the new desired value. Here's what I see when I change the language from en-US to fr (not shown here, but I also tested navigator.language, just to be sure it's the same as the first value of navigator.languages; it was): E/GeckoConsole( 1073): […] in l10n_langchange: navigator.languages: en-US, en E/GeckoConsole( 1073): […] in l10n_langchange: navigator.languages: fr, en-US, en Interestingly, here's what I see when I then change the language again, this time from fr to zh-TW: E/GeckoConsole( 1073): […] in l10n_langchange: navigator.languages: en-US, en E/GeckoConsole( 1073): […] in l10n_langchange: navigator.languages: zh-TW, en-US, en Not sure why it says "en-US, en" again on the first line. ::: bindings/l20n/runtime.js @@ +191,5 @@ > > function initLocale() { > this.ctx.requestLocales(navigator.language); > + window.addEventListener('languagechange', function l10n_langchange() { > + navigator.mozL10n.langauge.code = navigator.language; s/langauge/language/ :>
Attachment #8426696 - Flags: feedback?(stas) → feedback-
Depends on: 1016038
Comment on attachment 8426696 [details] [diff] [review] patch Review of attachment 8426696 [details] [diff] [review]: ----------------------------------------------------------------- I got curious and dug into Gecko a little bit to see why the event was emitted twice. Consequently, I filed and then fixed bug 1016038. Changing my f- to f+ as the patch should work correctly now. Let's just fix the typo before landing, please :)
Attachment #8426696 - Flags: feedback- → feedback+
As per https://groups.google.com/d/msg/mozilla.dev.gaia/LSL5d3EOPAM/_Gtmc-B1DWgJ, this will be useful for apps migrating away from being certified. Gandalf, do you want to land this today?
Flags: needinfo?(gandalf)
Blocks: 1016503
Comment on attachment 8426696 [details] [diff] [review] patch Review of attachment 8426696 [details] [diff] [review]: ----------------------------------------------------------------- Sure, stas. Can I get r+ on top of your f+? :) I fixed the typo on the branch
Attachment #8426696 - Flags: review?(stas)
Attached file pull request (deleted) —
pull request
Flags: needinfo?(gandalf)
Comment on attachment 8426696 [details] [diff] [review] patch Review of attachment 8426696 [details] [diff] [review]: ----------------------------------------------------------------- Thanks, r=me assuming Travis is green.
Attachment #8426696 - Flags: review?(stas) → review+
Blocks: 1018534
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: