diff --git a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts b/packages/angular_devkit/build_angular/src/utils/i18n-options.ts index da6652062b25..424e867d7bd1 100644 --- a/packages/angular_devkit/build_angular/src/utils/i18n-options.ts +++ b/packages/angular_devkit/build_angular/src/utils/i18n-options.ts @@ -283,6 +283,7 @@ export function loadTranslations( logger: { warn: (message: string) => void; error: (message: string) => void }, usedFormats?: Set, ) { + let translations: Record|undefined = undefined; for (const file of desc.files) { const loadResult = loader(path.join(workspaceRoot, file.path)); @@ -304,19 +305,20 @@ export function loadTranslations( file.format = loadResult.format; file.integrity = loadResult.integrity; - if (desc.translation) { + if (translations) { // Merge translations for (const [id, message] of Object.entries(loadResult.translations)) { - if (desc.translation[id] !== undefined) { + if (translations[id] !== undefined) { logger.warn( `WARNING [${file.path}]: Duplicate translations for message '${id}' when merging`, ); } - desc.translation[id] = message; + translations[id] = message; } } else { // First or only translation file - desc.translation = loadResult.translations; + translations = loadResult.translations; } } + desc.translation = translations; }