angular/angular-cli · error
*
Error message
*
What it means
During i18n extraction (extract-i18n builder), the localization diagnostics collector found duplicate translation message IDs. If duplicateTranslationBehavior is 'error', the builder logs 'Extraction Failed' with the formatted diagnostics and returns success:false; if 'warning' (default), it only logs the diagnostics as a warning.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/extract-i18n/builder.ts:132
return path.relative(from, to);
},
};
const duplicateTranslationBehavior = normalizedOptions.i18nOptions.duplicateTranslationBehavior;
const diagnostics = checkDuplicateMessages(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
checkFileSystem as any,
extractionResult.messages,
duplicateTranslationBehavior,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
extractionResult.basePath as any,
);
if (diagnostics.messages.length > 0 && duplicateTranslationBehavior !== 'ignore') {
if (duplicateTranslationBehavior === 'error') {
context.logger.error(`Extraction Failed: ${diagnostics.formatDiagnostics('')}`);
return { success: false };
} else {
context.logger.warn(diagnostics.formatDiagnostics(''));
}
}
// Serialize all extracted messages
const serializer = await createSerializer(
localizeToolsModule,
normalizedOptions.format,
normalizedOptions.i18nOptions.sourceLocale,
extractionResult.basePath,
extractionResult.useLegacyIds,
diagnostics,
);
assert(serializer);
const content = serializer.serialize(extractionResult.messages);
// Ensure directory existsView on GitHub (pinned to bb72145f9a)
Solutions
- Fix the duplicate i18n ids reported in the diagnostics output so each id maps to one source text.
- Set duplicateTranslationBehavior to 'warning' in the extract-i18n options to only warn instead of failing.
- Set duplicateTranslationBehavior to 'ignore' to suppress duplicates entirely (not recommended for translation integrity).
Example fix
// angular.json (extract-i18n options) // before "duplicateTranslationBehavior": "error" // after: fix ids in templates, e.g. give each a unique explicit id // <span i18n="@@greeting">Hello</span> vs <span i18n="@@farewell">Goodbye</span>
Defensive patterns
Strategy: validation
Validate before calling
// Deduplicate explicit i18n ids before extraction:
const ids = [...text.matchAll(/i18n="@@([^"]+)"/g)].map(m => m[1]);
const dupes = ids.filter((id, i) => ids.indexOf(id) !== i);
if (dupes.length) throw new Error(`Duplicate i18n ids: ${[...new Set(dupes)].join(', ')}`); Prevention
- Enforce unique explicit i18n ids via a lint rule (e.g., custom ESLint check or grep in CI).
- Set duplicateTranslationBehavior to 'error' in CI so duplicates fail builds early.
- Review i18n attributes when copy-pasting templates.
When it happens
Trigger: Running `ng extract-i18n` when two or more source messages produce the same i18n ID (explicit id attributes or auto-generated ids colliding) and duplicateTranslationBehavior is not 'ignore'.
Common situations: Two templates share an explicit i18n id with different source text; copy-pasted i18n attributes; auto-generated ids colliding after refactoring templates.
Related errors
- The development server only supports localizing a single loc
- *
- Locale data for '${locale}' cannot be found. Using locale da
- Locale data for '${locale}' cannot be found. No locale data
- Project '${projectName}' not found in workspace path ${works
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/c105a57c61866c3e.
Report an issue: GitHub.