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 exists

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Fix the duplicate i18n ids reported in the diagnostics output so each id maps to one source text.
  2. Set duplicateTranslationBehavior to 'warning' in the extract-i18n options to only warn instead of failing.
  3. 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

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


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/c105a57c61866c3e. Report an issue: GitHub.