Skip to content

Commit 92b4e06

Browse files
bbarrydgp1130
authored andcommittedJan 12, 2022
fix(@angular-devkit/build-angular): load translations fresh start
Currently when making a change while serving a localized application, duplicate translation warnings appear for every translation id. This fixes that by replacing the whole translation object with a new one each time translations are loaded. fixes #22398
1 parent 6ca0e41 commit 92b4e06

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

Diff for: ‎packages/angular_devkit/build_angular/src/utils/i18n-options.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export function loadTranslations(
283283
logger: { warn: (message: string) => void; error: (message: string) => void },
284284
usedFormats?: Set<string>,
285285
) {
286+
let translations: Record<string, unknown> | undefined = undefined;
286287
for (const file of desc.files) {
287288
const loadResult = loader(path.join(workspaceRoot, file.path));
288289

@@ -304,19 +305,20 @@ export function loadTranslations(
304305
file.format = loadResult.format;
305306
file.integrity = loadResult.integrity;
306307

307-
if (desc.translation) {
308+
if (translations) {
308309
// Merge translations
309310
for (const [id, message] of Object.entries(loadResult.translations)) {
310-
if (desc.translation[id] !== undefined) {
311+
if (translations[id] !== undefined) {
311312
logger.warn(
312313
`WARNING [${file.path}]: Duplicate translations for message '${id}' when merging`,
313314
);
314315
}
315-
desc.translation[id] = message;
316+
translations[id] = message;
316317
}
317318
} else {
318319
// First or only translation file
319-
desc.translation = loadResult.translations;
320+
translations = loadResult.translations;
320321
}
321322
}
323+
desc.translation = translations;
322324
}

0 commit comments

Comments
 (0)
Please sign in to comment.