Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular/build): only issue invalid i18n config error for duplicate subPaths with inlined locales #29422

Merged
merged 1 commit into from
Jan 21, 2025
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