{"record":{"id":"90359ba69858e15b","repo":"facebook/docusaurus","slug":"please-make-sure-all-theme-translations-are-static","errorCode":null,"errorMessage":"Please make sure all theme translations are static!\nSome warnings were found!\n\n${fileExtractedTranslations.warnings.join('\\n\\n')}\n","messagePattern":"Please make sure all theme translations are static!\nSome warnings were found!\n\n(.+?)\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-theme-translations/src/utils.ts","lineNumber":75,"sourceCode":"  targetDirs?: string[],\n): Promise<TranslationFileContent> {\n  // eslint-disable-next-line no-param-reassign\n  targetDirs ??= (await getThemes()).flatMap((theme) => theme.src);\n\n  const filePaths = (await globTranslatableSourceFiles(targetDirs)).filter(\n    (filePath) => ['.js', '.jsx'].includes(path.extname(filePath)),\n  );\n\n  const filesExtractedTranslations = await extractAllSourceCodeFileTranslations(\n    filePaths,\n    {\n      presets: [require.resolve('@docusaurus/babel/preset')],\n    },\n  );\n\n  filesExtractedTranslations.forEach((fileExtractedTranslations) => {\n    if (fileExtractedTranslations.warnings.length > 0) {\n      throw new Error(`Please make sure all theme translations are static!\nSome warnings were found!\n\n${fileExtractedTranslations.warnings.join('\\n\\n')}\n`);\n    }\n  });\n\n  const translations = filesExtractedTranslations.reduce(\n    (acc, extractedTranslations) => ({\n      ...acc,\n      ...extractedTranslations.translations,\n    }),\n    {},\n  );\n\n  return translations;\n}\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-theme-translations/src/utils.ts#L57-L93","documentation":"Thrown by extractThemeCodeMessages in docusaurus-theme-translations when the Babel-based translation extractor (extractAllSourceCodeFileTranslations) emits warnings for any source file. Docusaurus theme translations must be statically analyzable (literal translate() calls) so they can be extracted for localization; dynamic/generated message keys break extraction. Used by the update.mjs maintenance script and tests, not at runtime.","triggerScenarios":"Running the theme-translations update script (or its tests) against theme source that contains non-static translate usages: computed keys, template literals with expressions, function-wrapped messages, or unsupported babel patterns. Each file's warnings are aggregated and, if non-empty, the whole extraction aborts.","commonSituations":"Editing theme components (theme-classic, theme-common, theme-search-algolia) to use dynamic translation keys; introducing interpolate/translate calls the extractor can't statically resolve; refactoring that breaks the @docusaurus/babel preset extraction.","solutions":["Read the warnings printed in the error to find the offending file(s) and translate() usages.","Refactor those usages to static message keys (string literals, no interpolation in the key).","Re-run the update script (pnpm update:codeTranslations or the theme-translations update.mjs).","If a usage is intentionally dynamic, restructure to use a static key with parameters."],"exampleFix":"// before (non-static key)\nconst t = translate({ message: `Hello ${name}` });\n// after (static key, dynamic param)\nconst t = translate(\n  { message: 'Hello {name}' },\n  { name },\n);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await extractThemeCodeMessages(targetDirs);\n} catch (err) {\n  // err.message contains the per-file warnings; fix each translate() call,\n  // then re-run the extraction script.\n  console.error(err.message);\n  process.exit(1);\n}","preventionTips":["Always use static string-literal message keys in translate()/interpolate().","Run the theme-translations extraction in CI for theme packages so dynamic-key regressions fail the build.","Avoid composing translation keys at runtime; pass parameters instead."],"tags":["translations","i18n","babel","theme","maintainer-tooling"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}