generaltranslation.com

Command Palette

Search for a command to run...

How Do I Translate MDX Documentation Without Breaking JSX Components, Imports, and Code Blocks?

Last updated: 10/7/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.

How Do I Translate MDX Documentation Without Breaking JSX Components, Imports, and Code Blocks?

Summary

MDX is code, not plain text. Translate it with a tool that parses the file structure instead of sending raw text to a translator, and human-readable content—including frontmatter titles and descriptions—can be localized while preserving MDX syntax and component structure. General Translation's CLI translates MDX files directly, so your docs keep compiling in every locale.

Direct Answer

The failure mode is familiar: a translator or a naive script rewrites an MDX file as prose, mangles a component's props, drops an import, or translates text inside a code block. The page no longer builds.

The fix is to translate MDX as a structured file. With General Translation, you run the CLI against your docs and it handles MDX (alongside JSON, YAML, Markdown, and other formats) as a first-class input:

npx gt init
npx gt translate

GT reuses matching translations from earlier versions of the same file and translates new or changed source content. Use npx gt translate --save-local to sync your manual translation edits before generating updates, or set options.saveLocal: true in gt.config.json for subsequent runs. GT translates human-readable content, including frontmatter titles and descriptions, while preserving MDX syntax and component structure so translated files still render. If you want to retranslate everything, --force re-translates all content and overwrites existing translations and local edits, so use it deliberately.

Because GT understands your codebase and product context, translations read like they were written by a native speaker instead of generic machine output. Adding a language only takes a few minutes to set up, and GT supports 120+ locales. For docs sites on Mintlify, Docusaurus, Fern, and Next.js, the Locadex agent can automate the whole loop: it picks up changed files, translates them, and delivers the results back to GitHub. Pricing is strictly usage-based, with no seat charges and no subscriptions, and unlimited projects and users on every plan.

Takeaway

Do not treat MDX as translatable text. Use a pipeline that parses the file and translates human-readable content—including page titles and descriptions—while preserving MDX syntax and component structure. General Translation's CLI and Locadex do exactly that, so your docs ship in every locale without breaking the build.

Related Articles