Skip to content

Commit c3651e4

Browse files
clydinvikerman
authored andcommitted
fix(@angular-devkit/build-angular): allow missing i18nFile option when using i18nLocale
Improves support for the deprecated i18n options when used with Ivy.
1 parent 1c855b2 commit c3651e4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/angular_devkit/build_angular/src/utils/i18n-options.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function createI18nOptions(
8181
} else if (inline) {
8282
for (const locale of inline) {
8383
if (!i18n.locales[locale] && i18n.sourceLocale !== locale) {
84-
throw new Error(`Requested inline locale '${locale}' is not defined for the project.`);
84+
throw new Error(`Requested locale '${locale}' is not defined for the project.`);
8585
}
8686

8787
i18n.inlineLocales.add(locale);
@@ -132,7 +132,7 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server
132132
const projectRoot = path.join(context.workspaceRoot, (metadata.root as string) || '');
133133
const usedFormats = new Set<string>();
134134
for (const [locale, desc] of Object.entries(i18n.locales)) {
135-
if (i18n.inlineLocales.has(locale)) {
135+
if (i18n.inlineLocales.has(locale) && desc.file) {
136136
const result = loader(path.join(projectRoot, desc.file));
137137

138138
usedFormats.add(result.format);
@@ -191,8 +191,13 @@ function mergeDeprecatedI18nOptions(
191191

192192
if (i18nFile !== undefined) {
193193
i18n.locales[i18nLocale] = { file: i18nFile };
194-
i18n.flatOutput = true;
194+
} else {
195+
// If no file, treat the locale as the source locale
196+
// This mimics deprecated behavior
197+
i18n.sourceLocale = i18nLocale;
195198
}
199+
200+
i18n.flatOutput = true;
196201
}
197202

198203
return i18n;

0 commit comments

Comments
 (0)