Skip to content

Commit c87a38f

Browse files
committed
fix(@angular/build): only issue invalid i18n config error for duplicate subPaths with inlined locales
The i18n configuration validation was incorrectly flagging errors for identical `subPaths` when both locales were not inlined within the same build. This was due to the validation not properly accounting for the inlining of locales. This commit fixes this issue by ensuring that the validation only checks for duplicate `subPaths` when the locales are inlined. Closes #29398 (cherry picked from commit 334ec0f)
1 parent bd2ab46 commit c87a38f

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

packages/angular/build/src/utils/i18n-options.ts

+18-15
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,24 @@ export function createI18nOptions(
199199
}
200200
}
201201

202-
// Check that subPaths are unique.
203-
const localesData = Object.entries(i18n.locales);
202+
if (inline === true) {
203+
i18n.inlineLocales.add(i18n.sourceLocale);
204+
Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
205+
} else if (inline) {
206+
for (const locale of inline) {
207+
if (!i18n.locales[locale] && i18n.sourceLocale !== locale) {
208+
throw new Error(`Requested locale '${locale}' is not defined for the project.`);
209+
}
210+
211+
i18n.inlineLocales.add(locale);
212+
}
213+
}
214+
215+
// Check that subPaths are unique only the locales that we are inlining.
216+
const localesData = Object.entries(i18n.locales).filter(([locale]) =>
217+
i18n.inlineLocales.has(locale),
218+
);
219+
204220
for (let i = 0; i < localesData.length; i++) {
205221
const [localeA, { subPath: subPathA }] = localesData[i];
206222

@@ -215,19 +231,6 @@ export function createI18nOptions(
215231
}
216232
}
217233

218-
if (inline === true) {
219-
i18n.inlineLocales.add(i18n.sourceLocale);
220-
Object.keys(i18n.locales).forEach((locale) => i18n.inlineLocales.add(locale));
221-
} else if (inline) {
222-
for (const locale of inline) {
223-
if (!i18n.locales[locale] && i18n.sourceLocale !== locale) {
224-
throw new Error(`Requested locale '${locale}' is not defined for the project.`);
225-
}
226-
227-
i18n.inlineLocales.add(locale);
228-
}
229-
}
230-
231234
return i18n;
232235
}
233236

0 commit comments

Comments
 (0)