diff --git a/l10n.js b/l10n.js index 9c46564..99cf572 100644 --- a/l10n.js +++ b/l10n.js @@ -302,6 +302,8 @@ document.webL10n = (function(window, document, undefined) { // load and parse all resources for the specified locale function loadLocale(lang, callback) { + gReadyState = 'interactive'; + // RFC 4646, section 2.1 states that language tags have to be treated as // case-insensitive. Convert to lowercase for case-insensitive comparisons. if (lang) { @@ -339,9 +341,9 @@ document.webL10n = (function(window, document, undefined) { } else { consoleLog('no resource to load, early way out'); } + gReadyState = 'complete'; // early way out fireL10nReadyEvent(lang); - gReadyState = 'complete'; return; } @@ -352,8 +354,8 @@ document.webL10n = (function(window, document, undefined) { gResourceCount++; if (gResourceCount >= langCount) { callback(); - fireL10nReadyEvent(lang); gReadyState = 'complete'; + fireL10nReadyEvent(lang); } }; @@ -994,8 +996,6 @@ document.webL10n = (function(window, document, undefined) { // load the default locale on startup function l10nStartup() { - gReadyState = 'interactive'; - // most browsers expose the UI language as `navigator.language' // but IE uses `navigator.userLanguage' instead var userLocale = navigator.language || navigator.userLanguage; @@ -1180,7 +1180,7 @@ document.webL10n = (function(window, document, undefined) { ready: function(callback) { if (!callback) { return; - } else if (gReadyState == 'complete' || gReadyState == 'interactive') { + } else if (gReadyState == 'complete') { window.setTimeout(function() { callback(); });