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
- Initialize the i18n options (via the builder's i18n context/plugin) before invoking any inlining function.
- If writing a custom tool, replicate the builder's i18n setup steps (load locales, set i18n.flatOutput/inlineLocales) first.
- 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
- Always route inlining through the standard Angular builder pipeline that initializes i18n options.
- When calling utilities directly (scripts/tests), set up the i18n state first.
- Assert i18n options exist in unit tests before exercising inlining code paths.
- Avoid caching module state across worker boundaries where i18n context may be lost.
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
- esbuild implementation missing
- Flat output is only supported when inlining one locale.
- ${msg}\nAn error occurred inlining file "${options.filename}
- Unknown error occurred inlining file "${options.filename}"
- Unknown error occurred processing bundle for "${options.file
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/07eddcec1a699b23.
Report an issue: GitHub.