Bug 1410731 - Use multilocale.json as a locale set for L10nRegistry sources. r?mossop
MozReview-Commit-ID: 4SsInmlt1C4
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -92,19 +92,16 @@ var whitelist = [
// toolkit/components/places/ColorAnalyzer_worker.js
{file: "resource://gre/modules/ClusterLib.js"},
{file: "resource://gre/modules/ColorConversion.js"},
// Needed by HiddenFrame.jsm, but can't be packaged test-only
{file: "chrome://global/content/win.xul"},
- // List of built-in locales. See bug 1362617 for details.
- {file: "resource://gre/res/multilocale.json"},
-
// The l10n build system can't package string files only for some platforms.
{file: "resource://gre/chrome/en-US/locale/en-US/global-platform/mac/accessible.properties",
platforms: ["linux", "win"]},
{file: "resource://gre/chrome/en-US/locale/en-US/global-platform/mac/intl.properties",
platforms: ["linux", "win"]},
{file: "resource://gre/chrome/en-US/locale/en-US/global-platform/mac/platformKeys.properties",
platforms: ["linux", "win"]},
{file: "resource://gre/chrome/en-US/locale/en-US/global-platform/unix/accessible.properties",
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -664,21 +664,25 @@ BrowserGlue.prototype = {
textcolor: "white",
accentcolor: "black",
author: vendorShortName,
});
}
// Initialize the default l10n resource sources for L10nRegistry.
- const locales = [AppConstants.INSTALL_LOCALE];
- const toolkitSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
- L10nRegistry.registerSource(toolkitSource);
- const appSource = new FileSource("app", locales, "resource://app/localization/{locale}/");
- L10nRegistry.registerSource(appSource);
+ const multilocalePath = "resource://gre/res/multilocale.json";
+ L10nRegistry.bootstrap = fetch(multilocalePath).then(d => d.json()).then(({ locales }) => {
+ const toolkitSource = new FileSource("toolkit", locales, "resource://gre/localization/{locale}/");
+ L10nRegistry.registerSource(toolkitSource);
+ const appSource = new FileSource("app", locales, "resource://app/localization/{locale}/");
+ L10nRegistry.registerSource(appSource);
+ }).catch(e => {
+ Services.console.logStringMessage(`Could not load multilocale.json. Error: ${e}`);
+ });
Services.obs.notifyObservers(null, "browser-ui-startup-complete");
},
_checkForOldBuildUpdates() {
// check for update if our build is old
if (AppConstants.MOZ_UPDATER &&
Services.prefs.getBoolPref("app.update.enabled") &&
--- a/intl/l10n/L10nRegistry.jsm
+++ b/intl/l10n/L10nRegistry.jsm
@@ -73,26 +73,30 @@ Components.utils.importGlobalProperties(
* If during the life-cycle of the app a new source is added, the generator can be called again
* and will produce a new set of permutations placing the language pack provided resources
* at the top.
*/
const L10nRegistry = {
sources: new Map(),
ctxCache: new Map(),
+ bootstrap: null,
/**
* Based on the list of requested languages and resource Ids,
* this function returns an lazy iterator over message context permutations.
*
* @param {Array} requestedLangs
* @param {Array} resourceIds
* @returns {AsyncIterator<MessageContext>}
*/
async * generateContexts(requestedLangs, resourceIds) {
+ if (this.bootstrap !== null) {
+ await this.bootstrap;
+ }
const sourcesOrder = Array.from(this.sources.keys()).reverse();
for (const locale of requestedLangs) {
yield * generateContextsForLocale(locale, sourcesOrder, resourceIds);
}
},
/**
* Adds a new resource source to the L10nRegistry.