MDX files

在 2026.5 版被加入.

備註

Support for this format is under development. Some features might not yet be available and the behavior can change between releases. Feedback from testing is welcome.

MDX files are Markdown files with JSX syntax. Weblate extracts translatable Markdown text and preserves imports, exports, JSX components, and expressions.

MDX units automatically get the md-text and auto-safe-html flags. This keeps the unsafe HTML check active for plain text, standard HTML, and custom elements while avoiding HTML cleanup on MDX and JSX-like syntax. Use the explicit safe-html flag for strings that are known to contain HTML and should always be sanitized, including SVG or MathML snippets.

備註

Unlike most other formats, the changes in the translation files will not be imported to Weblate because it can not be done reliably. The source of truth for the translations is Weblate not the translated file.

也參考

MDX

範例檔案:

---
title: Ahoj světe!
description: Learn with Weblate
---

import LessonCard from "./LessonCard"
export const metadata = { slug: "intro" }

# Ahoj světe!

<LessonCard title="Keep this code" count={5}>
  Do not translate this JSX body.
</LessonCard>

Orangutan has five bananas.

Try Weblate at [weblate.org](https://demo.weblate.org/)!

*Thank you for using Weblate.*
支援的功能

副檔名

.mdx

語言能力

單語言

支援複數

No

支援描述

No

支援解釋

No

Supports context

No

Supports location

No

Supports flags

No

API 識別碼

mdx

支援唯讀字串

No

Check flags added by this format

auto-safe-html, strict-same, md-text

Weblate 配置

典型的 Weblate 組件配置

檔案遮罩

path/*.mdx

單語的基底語言檔案

path/en.mdx

新翻譯的範本

path/en.mdx

檔案格式

MDX file

檔案格式參數

mdx_merge_duplicates=True

處理重複字串

By default, Weblate treats each occurrence of a string as a separate translation unit to provide line-based context. This can be problematic in MDX tables or repeated component content, where reordering changes the context and can lead to translation loss.

To consolidate identical strings into a single translation unit, enable Deduplicate identical strings in the 檔案格式參數.

備註

Enabling this option disables line-based context for the merged units, ensuring that translations remain stable even if rows or sections are moved within the document.