支持文件类型 (Strings)

.JSON - i18next / i18nextV4 (Strings)

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

文件扩展名 

.json

API 扩展 

i18next / i18next_4

导入 

导出 

复数形式支持 

描述支持 

格式选项 

嵌套

i18next 和 i18nextV4 是 JavaScript 库,为基于 JavaScript 的各种环境提供易于使用的本地化和国际化解决方案。作为最古老的 l10n/i18n 库之一,它支持标准的 i18n 库功能,如插值和复数,并能很好地处理异步请求。配置后,它可以通过检测浏览器语言设置来自动加载特定区域的数据。

与其他 JavaScript l10n/i18n 库一样,i18next 和 i18nextV4 使用 JSON 格式存储翻译。待翻译的字符串要么直接放在值处,要么嵌套在另一个对象内部(例如内插值)。翻译时,确保所有变量都保持不变。

如果使用 i18nextV4,上传时选择 i18next 4 (.json) 格式。

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

两个版本对复数的处理不同。确定复数键:

  • i18next 使用:

    • 对于具有复杂复数规则的语言(如俄语),则使用 keyname_0keyname_1keyname_2keyname_5

    • 对于具有简单复数规则的语言(如英语),则使用 keynamekeyname_plural

  • i18nextV4 使用 _<plural_suffix> 结尾;使用文本 1、2、3 进行复数处理;或仅使用 keyname_onekeyname_other

GitHub 上 i18next 相关内容 

支持: 

  • 复数

    • 以 _0、_1、_other 等结尾的键将被映射到相应的复数形式。

  • 命名空间

  • 阵列

不支持: 

  • 区间复数作为正常键值保留。用户界面不支持。

  • 不直接支持嵌套/变量替换,但可以激活占位符。不支持在值中进行键的交叉引用。用户界面不支持。

格式选项

标识符 

嵌套

类型 

布尔值

上传 

下载 

默认 

true

说明 

导出翻译文件时,键是根据键名中的点嵌套的。设置为 false 以导出纯 JSON 格式的翻译文件。

代码示例(i18next_4)

{
  "boolean_key": "--- true\n",
  "empty_string_translation": "",
  "key_with_description":"Check it out!This key has a description!(At least in some formats)",
  "key_with_line-break":"This translations contains\na line-break.",
  "nested": {
    "deeply": {
      "key":"Wow, this key is nested even deeper."
    },
    "key":"This key is nested inside a namespace."
  },
  "null_translation": "",
  "sample_collection": [
    "first item",
    "second item",
    "third item"
  ],
  "simple_key":"Just a simple key with a simple message.",
  "unverified_key":"This translation is not yet verified and waits for it.(In some formats we also export this status)",
  "pluralized_key_one":"Only one pluralization found.",
  "pluralized_key_other":"Wow, you have %s pluralizations!"
}

代码示例(i18next)

{
  "boolean_key": "--- true\n",
  "empty_string_translation": "",
  "key_with_description":"Check it out!This key has a description!(At least in some formats)",
  "key_with_line-break":"This translations contains\na line-break.",
  "nested": {
    "deeply": {
      "key":"Wow, this key is nested even deeper."
    },
    "key":"This key is nested inside a namespace."
  },
  "null_translation": "",
  "sample_collection": [
    "first item",
    "second item",
    "third item"
  ],
  "simple_key":"Just a simple key with a simple message.",
  "unverified_key":"This translation is not yet verified and waits for it.(In some formats we also export this status)",
  "pluralized_key":"Only one pluralization found.",
  "pluralized_key_plural":"Wow, you have %s pluralizations!",
  “pluralized_keyWithCount”:“找到{{count}}复数。”,
  "pluralized_keyWithCount_plural":"哇,你有复数 {{count}} !"
}

GitHub 上 i18next 相关内容 

这篇文章有帮助吗?

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.