This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

Note: The behavior described below will be implemented in bug 993188.

The ready method is used to register a callback that will execute at least once.  The callback is registered as a listener to the ready event of the L10n context.  Additionally, if the L10n context is ready when L10n.ready() is called, the callback will be invoked immediately on the next tick of the event loop.

Using L10n.ready() is safer than registering a listener of the window's localized event because it also works when the localized event has already fired. This helps prevent intermittent race conditions, which would be hard to debug.

L10n.ready() is useful for executing code every time the language changes and/or when the L10n context first becomes ready (the 0th language change).

In order to schedule initialization tasks for when the localization is ready to be used for the first time (and this time only), use L10n.once().




The function to be executed everytime the L10n context is or becomes ready.


navigator.mozL10n.ready(function showLanguageDescription() {
  var lang = navigator.mozL10n.language.code

  // display the current locale in the main panel
  Settings.getSupportedLanguages(function displayLang(languages) {
    document.getElementById('language-desc').textContent = languages[lang];                                                                                                           │


Not part of any specification.

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API Firefox OS l10n Localization Method Reference Référence