Skip to main content
Version: 3.5.1

no-untranslated-text

强制 JSX 中的文本标签通过翻译调用进行换行。

¥Enforce text labels in JSX to be wrapped by translate calls.

当使用 国际化功能 时,此规则确保网站上出现的所有标签都是可翻译的,因此不会有任何字符串意外地漏掉未翻译的内容。

¥When the i18n feature is used, this rule ensures that all labels appearing on the website are translatable, so no string accidentally slips through untranslated.

规则详情

¥Rule Details

此规则的错误代码示例:

¥Examples of incorrect code for this rule:

// Hello World is not translated
<Component>Hello World</Component>

此规则的正确代码示例:

¥Examples of correct code for this rule:

// Hello World is translated
<Component>
<Translate>Hello World</Translate>
</Component>

规则配置

¥Rule Configuration

接受的字段:

¥Accepted fields:

选项类型默认描述
ignoredStringsstring[][]仅包含此列表中的字符串的文本标签将不会被报告。

何时不使用它

¥When Not To Use It

如果你不使用 国际化功能,则可以禁用此规则。你还可以在不需要翻译文本的地方禁用此规则。

¥If you're not using the i18n feature, you can disable this rule. You can also disable this rule where the text is not supposed to be translated.

进一步阅读

¥Further Reading