{"record":{"id":"d22bef4119d95db6","repo":"facebook/docusaurus","slug":"localized-value-for-config-key-key-not-found-fo","errorCode":null,"errorMessage":"Localized value for config key=${key} not found for both currentLocale=${currentLocale} or defaultLocale=${defaultLocale}","messagePattern":"Localized value for config key=(.+?) not found for both currentLocale=(.+?) or defaultLocale=(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"website/docusaurus.config.ts","lineNumber":159,"sourceCode":"\nconst isRsdoctor = process.env.RSDOCTOR === 'true';\n\n/*\nconst TwitterSvg =\n  '<svg style=\"fill: #1DA1F2; vertical-align: middle; margin-left: 3px;\" width=\"16\" height=\"16\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path d=\"M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z\"></path></svg>';\n*/\n\nconst defaultLocale = 'en';\n\nfunction getLocalizedConfigValue(key: keyof typeof ConfigLocalized) {\n  const currentLocale = process.env.DOCUSAURUS_CURRENT_LOCALE ?? defaultLocale;\n  const values = ConfigLocalized[key];\n  if (!values) {\n    throw new Error(`Localized config key=${key} not found`);\n  }\n  const value = values[currentLocale] ?? values[defaultLocale];\n  if (!value) {\n    throw new Error(\n      `Localized value for config key=${key} not found for both currentLocale=${currentLocale} or defaultLocale=${defaultLocale}`,\n    );\n  }\n  return value;\n}\n\n// By default, we don't want to run \"git log\" commands on i18n sites\n// This makes localized sites build much slower on Netlify\n// See also https://github.com/facebook/docusaurus/issues/11208\n// const showLastUpdate = process.env.DOCUSAURUS_CURRENT_LOCALE === defaultLocale;\nconst showLastUpdate = true;\n\nexport default async function createConfigAsync() {\n  return {\n    title: 'Docusaurus',\n    tagline: getLocalizedConfigValue('tagline'),\n    organizationName: 'facebook',\n    projectName: 'docusaurus',","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/website/docusaurus.config.ts#L141-L177","documentation":"Thrown by getLocalizedConfigValue() when the key DOES exist in ConfigLocalized but the value object has neither an entry for the current locale (DOCUSAURUS_CURRENT_LOCALE) nor for the default locale ('en'). The fallback chain is `values[currentLocale] ?? values[defaultLocale]`; if both are falsy, the build aborts. The message reports both the current and default locale so you know exactly which translations are missing.","triggerScenarios":"Building a localized site with DOCUSAURUS_CURRENT_LOCALE=fr where a ConfigLocalized key only has, say, a `de` entry and no `en` or `fr`; someone added a localized key but only filled in a non-default, non-target locale; an entry whose 'en' value was set to an empty string (falsy) which also fails the `if (!value)` guard.","commonSituations":"Adding a new locale for a deploy preview before all config keys are translated; a translator filled in `fr` but the default `en` entry was deleted; empty-string values silently treated as missing because the guard uses truthiness rather than key presence.","solutions":["Ensure ConfigLocalized[key] has at least an 'en' value — the default-locale fallback guarantees any locale build works.","If building a specific locale, add that locale's value too for a complete translation.","Replace empty-string values with real content, since the truthiness guard treats '' as missing.","Verify DOCUSAURUS_CURRENT_LOCALE matches a locale code you actually populated."],"exampleFix":"// before\nconst ConfigLocalized = {\n  tagline: { de: 'Baustatische...' }, // no en, no current locale\n};\n// after\nconst ConfigLocalized = {\n  tagline: { en: 'Build optimized sites...', de: '...', fr: '...' },\n};","handlingStrategy":"validation","validationCode":"const DEFAULT_LOCALE = 'en';\n\nfunction assertLocalizedValue(\n  map: Record<string, Record<string, string>>,\n  key: string,\n  currentLocale: string,\n) {\n  const values = map[key];\n  const value = values?.[currentLocale] ?? values?.[DEFAULT_LOCALE];\n  if (!value) {\n    throw new Error(\n      `Missing localized value for '${key}': need either '${currentLocale}' or '${DEFAULT_LOCALE}'.`,\n    );\n  }\n}\n\n// pre-build: for (const key of Object.keys(ConfigLocalized))\n//   assertLocalizedValue(ConfigLocalized, key, process.env.DOCUSAURUS_CURRENT_LOCALE ?? 'en');","typeGuard":"const hasLocalizedValue = (\n  values: Record<string, string> | undefined,\n  locale: string,\n  fallback = 'en',\n): boolean => Boolean(values?.[locale] ?? values?.[fallback]);","tryCatchPattern":null,"preventionTips":["Always populate the default 'en' entry when adding a localized key — it is the universal fallback.","Disallow empty-string localized values in CI (treat '' as missing).","Run the localized build for each locale in CI to catch missing translations early."],"tags":["i18n","config","localization","website-internal"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}