支持文件类型 (Strings)

.JSON - React-Intl 简单(字符串)

文本由 Phrase Language AI 从英语机器翻译而得。

文件扩展名

.json

API 扩展

react_simple_json

导入

导出

复数形式支持

描述支持

是的,使用默认消息提取

React-Intl 是一个专为简化国际化(i18n)和本地化而设计的 JavaScript 库,主要适用于在 React 中开发的应用程序。默认情况下,React-Intl 使用 .js 文件存储其本地化内容。本地化内容被解耦到标准化的 .JSON 文件(React-Intl 简单 JSON)中,以便在源代码中引用。

如果使用嵌套消息,请使用 React-Intl 嵌套 JSON 格式。这在 React Intl v2 中已过时。

AI 聊天机器人可以非常有效地从 .JSON 文件生成键列表。

代码示例

{
  "boolean_key": "--- true\n",
  "empty_string_translation": "",
  "key_with_description": "看看这个!这个键有一个描述!(至少在某些格式中)\
  "key_with_line-break": "此翻译包含\n一个换行符。",
  "nested.deeply.key": "我是一把深度嵌套的钥匙。",
  "nested.key": "此键嵌套在一个命名空间内。",
  "null_translation": null,
  "pluralized_key.one": "只找到一只小猫。",
  "pluralized_key.other": "哇,你有 %s 只小猫!",
  "pluralized_key.zero": "你没有小猫。",
  "sample_collection": [
    "first item",
    "second item",
    "third item"
  ],
  "simple_key": "简单的键,简单的信息,如此简单。",
  "unverified_key": "此翻译尚未验证,正在等待验证。"(在某些格式中,我们也导出此状态)"
}

使用 React Intl

翻译通常位于 .js 文件中:

module.exports = {
    "locales": ["en-US"],
    "messages": {
        "hello" : "World",
        other_hello : '其他世界',
    },
    "formats": {}
};

将消息移动到单独的本地化文件,例如 en-US.json:

{
    "hello" : "World",
    other_hello : '其他世界',
}

确保消息具有有效 .JSON 语法

{
    "hello" : "World",
    "other_hello" : "Other World"
}

用 require 语句包含消息:

module.exports = {
    "locales": ["en-US"],
    "messages": require('./en-US.json'),
    "formats": {}
};

React-Intl Simple JSON 格式现在可用于上传/下载 React Intl 本地化文件。

JSON 文件复数

各种库中最常见的复数键信息格式:

"messages": {
    "one": "一条消息已接收。","
    "other": "%s 条消息已接收。","
    "zero": "没有消息接收。"
}
这篇文章有帮助吗?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.