angular/angular-cli · error · Error
${message}
Error message
${message} What it means
During i18n inlining, duplicate translation detection reports issues via a warn/error callback. The error callback rethrows the message as an Error, so duplicate-translation problems configured as errors abort the build with the translator's message verbatim.
Source
Thrown at packages/angular_devkit/build_angular/src/utils/i18n-webpack.ts:103
}
if (!desc.files.length) {
continue;
}
loader ??= await createTranslationLoader();
loadTranslations(
locale,
desc,
context.workspaceRoot,
loader,
{
warn(message) {
context.logger.warn(message);
},
error(message) {
throw new Error(message);
},
},
usedFormats,
buildOptions.i18nDuplicateTranslation,
);
if (usedFormats.size > 1 && tsConfig.options.enableI18nLegacyMessageIdFormat !== false) {
// This limitation is only for legacy message id support (defaults to true as of 9.0)
throw new Error(
'Localization currently only supports using one type of translation file format for the entire application.',
);
}
}
// If inlining store the output in a temporary location to facilitate post-processing
if (i18n.shouldInline) {
// TODO: we should likely save these in the .angular directory in the next major version.
// We'd need to do a migration to add the temp directory to gitignore.View on GitHub (pinned to bb72145f9a)
Solutions
- Deduplicate the translation units in your locale files (unique ids/keys).
- Set "i18nDuplicateTranslation": "warning" (or "ignore") in angular.json i18n options to downgrade the behavior.
- Split overlapping translation files or restrict your translation file globs so each unit appears once.
- Rename duplicate trans-unit ids in XLIFF or remove repeated messages in XTB/JSON files.
Example fix
// before (angular.json)
"i18n": { "duplicateTranslation": "error" }
// after
"i18n": { "duplicateTranslation": "warning" } Defensive patterns
Strategy: try-catch
Validate before calling
const seen = new Set();
for (const unit of translationUnits) {
if (seen.has(unit.id)) console.warn(`Duplicate translation unit: ${unit.id}`);
seen.add(unit.id);
} Try / catch
try {
await configureI18nBuild(context, options);
} catch (err) {
// message is the raw duplicate-translation report
if (/duplicate/i.test(err.message)) {
console.error('Deduplicate trans-unit ids/keys in locale files or set i18nDuplicateTranslation to "warning".');
} else throw err;
} Prevention
- Set i18nDuplicateTranslation to 'warning' if duplicates are acceptable in your workflow.
- Run a lint step that checks for duplicate trans-unit ids in XLIFF/JSON files.
- Restrict translation file globs so the same unit isn't loaded twice.
- Deduplicate after CAT-tool exports before committing locale files.
When it happens
Trigger: `i18nDuplicateTranslation` set to 'error' (the default in many versions) while the same translation key/messageId appears more than once in translation files (e.g. duplicate <trans-unit> ids or repeated meaning/description pairs) across locale files loaded via makeTranslationLoader.
Common situations: Merging translation files from multiple translators; duplicated trans-unit IDs after CAT-tool exports; multiple translation files (glob patterns) containing overlapping units; upgrading and enabling stricter duplicate checks.
Related errors
- *
- The development server only supports localizing a single loc
- The builder requires a target.
- Localization currently only supports using one type of trans
- Flat output is only supported when inlining one locale.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/d4482b72623f3c05.
Report an issue: GitHub.