MDX files¶
Added in version 2026.5.
备注
我们正在开发对这种格式的支持。某些功能也许上不可用,且不同版本间的行为也不一样。欢迎从测试得来的反馈。
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.
备注
和其他多数格式不同,翻译文件的更改不会被导入到 Weblate,因为无法可靠地完成这一任务。翻译真实性源自 Weblate 而不是已翻译的文件。
参见
示例文件:
---
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.*
文件扩展名 |
|
|---|---|
Linguality ⓘ |
单语言 |
支持复数 ⓘ |
|
支持描述 ⓘ |
|
支持解释 ⓘ |
|
支持上下文 ⓘ |
|
支持位置 ⓘ |
|
支持标记 ⓘ |
|
API 标识符 |
|
支持只读字符串 ⓘ |
|
Check flags added by this format ⓘ |
|
Weblate 配置¶
典型的 Weblate 部件配置 |
|
|---|---|
文件掩码 |
|
单语言译文模版语言文件 |
|
新语种的翻译模版 |
|
文件格式 |
MDX file |
文件格式参数 |
|
处理重复的字符串¶
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.
整合相同字符串到单一翻译单元,在 文件格式参数 中启用 Deduplicate identical strings.
备注
启用此选项为已合并单元禁用基于行的上下文,确保即使行或部分在文档内移动译文也保持稳定。