<a id="go-i18n-json"></a>

# go-i18n JSON 文件

<a id="index-0"></a>

#### Versionadded
Added in version 4.1.

#### Versionchanged
在 4.16 版本发生变更: 添加了对此格式 v2 变体的支持。

go-i18n 翻译是单语言的因此建议使用（最常见的）英文字符串指定一个基本文件。

#### NOTE
Weblate 支持 go-i18n JSON v1 和 v2 变体。请选择匹配你环境的正确文件格式。

#### SEE ALSO
* [JSON](https://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/json.html)
* [go-i18n](https://github.com/nicksnyder/go-i18n)
* [更新目标语言文件](https://docs.weblate.org/zh-cn/latest/devel/integration.md#updating-target-files)
* [自定义 JSON 输出](https://docs.weblate.org/zh-cn/latest/admin/addons.md#addon-weblate-json-customize)
* [清理翻译文件](https://docs.weblate.org/zh-cn/latest/admin/addons.md#addon-weblate-cleanup-generic)

## 示例文件

示例文件 v1：

```json
[
  {
    "id": "hello",
    "description": "Description",
    "translation": "Ahoj světe!\n"
  },
  {
    "id": "orangutan",
    "description": "Description",
    "translation": {
      "one": "Orangutan has {{.Count}} banana.\n",
      "other": "Orangutan has {{.Count}} bananas.\n"
    }
  },
  {
    "id": "try",
    "description": "Description",
    "translation": ""
  },
  {
    "id": "thanks",
    "description": "Description",
    "translation": ""
  }
]
```

示例文件 v2：

```json
{
  "hello": "Ahoj světe!\n",
  "orangutan": {
    "description": "Description",
    "one": "Orangutan has {{.Count}} banana.\n",
    "other": "Orangutan has {{.Count}} bananas.\n"
  },
  "try": {
    "description": "Description",
    "other": ""
  },
  "thanks": {
    "description": "Description",
    "other": ""
  }
}
```

<!-- AUTOGENERATED START: format-features go-i18n-toml -->
<!-- This section is automatically generated by `./manage.py list_format_features`. Do not edit manually. -->

#### 支持的功能

| 文件扩展名                                                                       | `.toml`        |
|-----------------------------------------------------------------------------|----------------|
| Linguality [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#bimono)          | 单语言            |
| 支持复数 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-plurals)        | `Yes`          |
| 支持描述 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-description)    | `No`           |
| 支持解释 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-explanation)    | `No`           |
| 支持上下文 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-context)       | `No`           |
| 支持位置 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-location)       | `No`           |
| 支持标记 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-flags)          | `No`           |
| API 标识符                                                                     | `go-i18n-toml` |
| 支持只读字符串 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#read-only-strings)  | `No`           |
| 支持删除过时字符串 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#obsolete-strings) | `No`           |
<!-- AUTOGENERATED END: format-features go-i18n-toml -->
<!-- AUTOGENERATED START: format-features go-i18n-json -->
<!-- This section is automatically generated by `./manage.py list_format_features`. Do not edit manually. -->

#### 支持的功能

| 文件扩展名                                                                       | `.json`                           |
|-----------------------------------------------------------------------------|-----------------------------------|
| Linguality [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#bimono)          | 单语和双语                             |
| 支持复数 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-plurals)        | `Yes`                             |
| 支持描述 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-description)    | `Yes`                             |
| 支持解释 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-explanation)    | `No`                              |
| 支持上下文 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-context)       | `No`                              |
| 支持位置 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-location)       | `No`                              |
| 支持标记 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-flags)          | `No`                              |
| API 标识符                                                                     | `go-i18n-json`, `go-i18n-json-v2` |
| 支持只读字符串 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#read-only-strings)  | `No`                              |
| 支持删除过时字符串 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#obsolete-strings) | `No`                              |
<!-- AUTOGENERATED END: format-features go-i18n-json -->

## Weblate 配置

|             | 典型的 Weblate [部件配置](https://docs.weblate.org/zh-cn/latest/admin/projects.md#component) for v1   |
|-------------|------------------------------------------------------------------------------------|
| 文件掩码        | `langs/*.json`                                                                     |
| 单语言译文模版语言文件 | `langs/en.json`                                                                    |
| 新语种的翻译模版    | 空                                                                                  |
| 文件格式        | go-i18n v1 JSON 文件                                                                 |

|             | 典型的适用于 v2 的 Weblate [部件配置](https://docs.weblate.org/zh-cn/latest/admin/projects.md#component)   |
|-------------|-------------------------------------------------------------------------------------|
| 文件掩码        | `langs/*.json`                                                                      |
| 单语言译文模版语言文件 | `langs/en.json`                                                                     |
| 新语种的翻译模版    | 空                                                                                   |
| 文件格式        | go-i18n v2 JSON 文件                                                                  |
