From 3d1443faf01364e5ebb159fd55c8f795e78426d5 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Thu, 13 Feb 2020 18:41:25 +0000 Subject: [PATCH] Bug 1613569 - Deduplicate resources when generating bundles. r=stas Differential Revision: https://phabricator.services.mozilla.com/D62621 --HG-- extra : moz-landing-system : lando --- intl/l10n/L10nRegistry.jsm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/intl/l10n/L10nRegistry.jsm b/intl/l10n/L10nRegistry.jsm index ac52edbcaaba..100080526b3a 100644 --- a/intl/l10n/L10nRegistry.jsm +++ b/intl/l10n/L10nRegistry.jsm @@ -134,10 +134,11 @@ class L10nRegistryService { * @returns {AsyncIterator} */ async* generateBundles(requestedLangs, resourceIds) { + const resourceIdsDedup = Array.from(new Set(resourceIds)); const sourcesOrder = Array.from(this.sources.keys()).reverse(); const pseudoNameFromPref = Services.prefs.getStringPref("intl.l10n.pseudo", ""); for (const locale of requestedLangs) { - for await (const dataSets of generateResourceSetsForLocale(locale, sourcesOrder, resourceIds)) { + for await (const dataSets of generateResourceSetsForLocale(locale, sourcesOrder, resourceIdsDedup)) { const bundle = new FluentBundle(locale, { ...MSG_CONTEXT_OPTIONS, transform: PSEUDO_STRATEGIES[pseudoNameFromPref], @@ -166,10 +167,11 @@ class L10nRegistryService { * @returns {Iterator} */ * generateBundlesSync(requestedLangs, resourceIds) { + const resourceIdsDedup = Array.from(new Set(resourceIds)); const sourcesOrder = Array.from(this.sources.keys()).reverse(); const pseudoNameFromPref = Services.prefs.getStringPref("intl.l10n.pseudo", ""); for (const locale of requestedLangs) { - for (const dataSets of generateResourceSetsForLocaleSync(locale, sourcesOrder, resourceIds)) { + for (const dataSets of generateResourceSetsForLocaleSync(locale, sourcesOrder, resourceIdsDedup)) { const bundle = new FluentBundle(locale, { ...MSG_CONTEXT_OPTIONS, transform: PSEUDO_STRATEGIES[pseudoNameFromPref],