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..8bce4ab4d9e9 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|null = null; for (const file of desc.files) { const loadResult = loader(path.join(workspaceRoot, file.path)); @@ -307,16 +308,17 @@ export function loadTranslations( if (desc.translation) { // 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; }