angular/angular-cli · error · Error

i18n options are missing

Error message

i18n options are missing

What it means

inlineCopyOnly (and the inlining flow generally) requires the module-level i18n options to have been initialized via the i18n plugin machinery. If inlineCopyOnly is called with i18n still undefined, the library cannot know locales or output layout and throws 'i18n options are missing'.

Source

Thrown at packages/angular_devkit/build_angular/src/utils/process-bundle.ts:308

      options.filename,
    );
    await fs.writeFile(outputPath, outputCode);

    if (inputMap && outputMap) {
      outputMap.file = options.filename;
      if (mapSourceRoot) {
        outputMap.sourceRoot = mapSourceRoot;
      }
      await fs.writeFile(outputPath + '.map', JSON.stringify(outputMap));
    }
  }

  return { file: options.filename, diagnostics: diagnostics.messages, count: positions.length };
}

async function inlineCopyOnly(options: InlineOptions) {
  if (!i18n) {
    throw new Error('i18n options are missing');
  }

  for (const locale of i18n.inlineLocales) {
    const subPath = i18n.locales[locale].subPath;
    const outputPath = path.join(
      options.outputPath,
      i18n.flatOutput ? '' : subPath,
      options.filename,
    );
    await fs.writeFile(outputPath, options.code);
    if (options.map) {
      await fs.writeFile(outputPath + '.map', options.map);
    }
  }

  return { file: options.filename, diagnostics: [], count: 0 };
}

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Initialize the i18n options (via the builder's i18n context/plugin) before invoking any inlining function.
  2. If writing a custom tool, replicate the builder's i18n setup steps (load locales, set i18n.flatOutput/inlineLocales) first.
  3. In tests, mock or set the module's i18n state to a valid InlineOptions-compatible object.

Example fix

// before
customBundle();
inlineCopyOnly(options); // throws: i18n never initialized
// after
setupI18nContext(ngI18nOptions); // initializes i18n state first
inlineCopyOnly(options);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof i18nOptions === 'undefined' || i18nOptions == null) {
  throw new Error('Initialize i18n options before calling inlining utilities.');
}

Type guard

function i18nInitialized(i18n: unknown): i18n is NonNullable<typeof i18n> {
  return i18n !== null && i18n !== undefined;
}

Try / catch

try {
  await inlineCopyOnly(options);
} catch (e) {
  if (String(e.message).includes('i18n options are missing')) {
    // initialize i18n context and retry once
  } else throw e;
}

Prevention

When it happens

Trigger: Calling inlineCopyOnly (directly or via inlineLocales/inlineLocalesDirect) before the i18n options were set up — e.g. invoking the inlining utilities outside the normal builder pipeline where the i18n context was never initialized.

Common situations: Custom scripts or tools that import process-bundle utilities directly without calling the i18n initialization; using the utilities in tests without stubbing the i18n options; internal state lost across worker/process boundaries.

Related errors


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