支持文件类型 (Strings)

.JSON - 简单(字符串)

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

文件扩展名

.json

API 扩展

simple_json

导入

是

导出

是

复数形式支持

是

描述支持

否

格式选项

这些选项可以在上传和/或下载文件时指定。根据上传/下载方式(API、CLI、仓库同步等),它们可以在查询参数 上传、下载 或 phrase.yml 配置文件中指定。

enable_pluralization, preserve_data_types

.JSON(JavaScript 对象表示法)最初仅为 JavaScript 设计,但后来与 .XML、.YAML、.Properties 等并行成为一种标准交换文件格式。.JSON 由包裹在花括号中的键值对组成。值可以是字符串、数字或对象(一个或多个包裹在花括号中的键值对)。简单 JSON 是一种 .JSON 文件,除复数形式外,大多数值都是纯字符串。在这种情况下,作为值放置的字符串将被翻译。

AI 聊天机器人在从 .JSON 文件生成键列表方面非常有效。

格式选项

标识符

enable_pluralization

类型

boolean

上传

是

下载

否

默认

true

描述

启用复数键检测。所有匹配的键都将作为复数键持久化。

标识符

preserve_data_types

类型

boolean

上传

否

下载

是

默认

false

描述

启用后,在键的 Meta 部分中被定义为 Number 或 Boolean 类型的键将导出为真实的 JSON 数字或布尔值,而不是带引号的字符串。禁用后(默认),无论声明的类型如何,所有键值都将导出为字符串。

代码示例

{
  "boolean_key": "--- true\n",
  "empty_string_translation": "",
  "key_with_description":“请查看!”此键有一个描述!(至少在某些格式中)”,
  "key_with_line-break":"This translations contains\na line-break.",
  "nested.deeply.key":"Wow, this key is nested even deeper.",
  "nested.key":"This key is nested inside a namespace.",
  "null_translation": null,
  "pluralized_key": {
    "one":“仅找到一个复数形式。”
    "other":“哇,你有 %s 个复数形式!”
    "zero":“你没有复数形式。”
  },
  "sample_collection": [
    "first item",
    "second item",
    "third item"
  ],
  "simple_key":"Just a simple key with a simple message.",
  "unverified_key":“此翻译尚未经过验证,等待确认。(在某些格式中,我们也导出此状态)”
}

复数形式

此格式使用命名类别来标识键的不同复数形式。以下类别保留用于复数形式:

.zero | .one | .two | .few | .many | .other

正确识别、持久化并标记的复数键的示例名称:

  • inbox.messages.notification.one

  • inbox.messages.notification.other

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.