Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions packages/angular/build/src/utils/i18n-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,24 @@ export function createI18nOptions(
}
}

// Check that subPaths are unique.
const localesData = Object.entries(i18n.locales);
if (inline === true) {
i18n.inlineLocales.add(i18n.sourceLocale);
Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
} else if (inline) {
for (const locale of inline) {
if (!i18n.locales[locale] && i18n.sourceLocale !== locale) {
throw new Error(`Requested locale '${locale}' is not defined for the project.`);
}

i18n.inlineLocales.add(locale);
}
}

// Check that subPaths are unique only the locales that we are inlining.
const localesData = Object.entries(i18n.locales).filter(([locale]) =>
i18n.inlineLocales.has(locale),
);

for (let i = 0; i < localesData.length; i++) {
const [localeA, { subPath: subPathA }] = localesData[i];

Expand All @@ -209,19 +225,6 @@ export function createI18nOptions(
}
}

if (inline === true) {
i18n.inlineLocales.add(i18n.sourceLocale);
Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
} else if (inline) {
for (const locale of inline) {
if (!i18n.locales[locale] && i18n.sourceLocale !== locale) {
throw new Error(`Requested locale '${locale}' is not defined for the project.`);
}

i18n.inlineLocales.add(locale);
}
}

return i18n;
}

Expand Down
Loading