Bug 1613569 - Deduplicate resources when generating bundles. r=stas

Differential Revision: https://phabricator.services.mozilla.com/D62621

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Zibi Braniecki 2020-02-13 18:41:25 +00:00
parent 24e4bee487
commit 3d1443faf0

View File

@ -134,10 +134,11 @@ class L10nRegistryService {
* @returns {AsyncIterator<FluentBundle>}
*/
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<FluentBundle>}
*/
* 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],