{"record":{"id":"92261f6620f06bcb","repo":"angular/angular-cli","slug":"flat-output-is-only-supported-when-inlining-one-lo","errorCode":null,"errorMessage":"Flat output is only supported when inlining one locale.","messagePattern":"Flat output is only supported when inlining one locale\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/utils/process-bundle.ts","lineNumber":114,"sourceCode":"\n  return { diagnostics, plugins };\n}\n\ninterface LocalizePosition {\n  start: number;\n  end: number;\n  messageParts: TemplateStringsArray;\n  expressions: types.Expression[];\n}\n\nconst localizeName = '$localize';\n\nexport async function inlineLocales(options: InlineOptions) {\n  if (!i18n || i18n.inlineLocales.size === 0) {\n    return { file: options.filename, diagnostics: [], count: 0 };\n  }\n  if (i18n.flatOutput && i18n.inlineLocales.size > 1) {\n    throw new Error('Flat output is only supported when inlining one locale.');\n  }\n\n  const hasLocalizeName = options.code.includes(localizeName);\n  if (!hasLocalizeName && !options.setLocale) {\n    return inlineCopyOnly(options);\n  }\n\n  await loadLocalizeTools();\n\n  let ast: ParseResult | undefined | null;\n  try {\n    ast = parseSync(options.code, {\n      babelrc: false,\n      configFile: false,\n      sourceType: 'unambiguous',\n      filename: options.filename,\n    });\n  } catch (error) {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/utils/process-bundle.ts#L96-L132","documentation":"The Angular CLI's i18n inlining step throws this when 'flat output' (writing translated bundles without per-locale subdirectories) is requested but more than one locale is being inlined. Flat output can only unambiguously hold a single locale's translations, so the library rejects the combination up front in inlineLocales.","triggerScenarios":"Calling inlineLocales with i18n.flatOutput enabled while i18n.inlineLocales contains 2 or more locales — e.g. an Angular project configured with `\"localize\": [\"en\", \"fr\"]` plus `outputPath`/i18n settings that yield flat output.","commonSituations":"angular.json mistakes: setting `localize` to an array of locales while configuring the build for flat output (e.g. via `i18n` browser-builder options or missing `subPath` configuration); upgrading projects that previously inlined one locale and then adding a second locale without switching to per-locale subdirectory output.","solutions":["Reduce the set of locales being inlined to exactly one (e.g. run the build once per locale with `--localize=fr`).","Disable flat output so each locale is written to its own subdirectory under outputPath.","Check angular.json: ensure `projects.<p>.architect.build.options.localize` and i18n output options are consistent — multiple locales require non-flat output."],"exampleFix":"// angular.json - before\n\"options\": { \"localize\": [\"en\", \"fr\"], \"outputPath\": \"dist/app\" }\n// after\n\"options\": { \"localize\": true, \"outputPath\": \"dist/app\" } // per-locale subdirs: dist/app/en, dist/app/fr","handlingStrategy":"validation","validationCode":"if (i18nOptions.flatOutput && i18nOptions.inlineLocales.size > 1) {\n  throw new Error('Flat output requires exactly one locale; use per-locale subdirectories instead.');\n}","typeGuard":"function supportsFlatOutput(i18n: { flatOutput: boolean; inlineLocales: Set<string> }): boolean {\n  return !(i18n.flatOutput && i18n.inlineLocales.size > 1);\n}","tryCatchPattern":"try {\n  await inlineLocales(options);\n} catch (e) {\n  if (e.message.includes('Flat output is only supported')) {\n    // fall back to non-flat output or single-locale runs\n  } else throw e;\n}","preventionTips":["Only enable flat output when building a single locale.","Prefer the default per-locale subdirectory output when localizing multiple locales.","Validate angular.json `localize` and i18n output options in CI before building.","Run `ng build --localize=fr` per locale instead of batching locales with flat output."],"tags":["i18n","angular-cli","configuration","build"],"backgroundTag":"invalid-configuration-combination","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}