<a id="csv"></a>

# CSV 文件

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

CSV 文件可以包含一个原文和译文的简单列表。Weblate 支持以下文件：

* 带有标头定义字段（`location`, `source`, `target`, `ID`, `fuzzy`, `context`, `translator_comments`, `developer_comments`）的文件。这是推荐的方法，因为它最不容易出错。挑选 CSV file 作为一种文件格式。
* 具有两个字段的文件——原文和译文（按此顺序），选择 简单 CSV 文件 作为文件格式。
* 无标头文件，其字段按 [translate-toolkit](https://toolkit.translatehouse.org/) 定义的顺序排列：`location`、`source`、`target`、`ID`、`fuzzy`、`context`、`translator_comments`、`developer_comments`。选择 CSV 文件 作为文件格式。
* 当你的文件是单语言时记得定义 [单语言译文模版语言文件](https://docs.weblate.org/zh-cn/latest/admin/projects.md#component-template)（参见 [双语和单语格式](https://docs.weblate.org/zh-cn/latest/formats.md#bimono)）。

CSV parsing accepts at most 100,000 data rows per file. The header and blank lines
do not count toward this limit. Quoted multiline values remain part of one row,
while each plural-form row counts separately. This limit also applies when
Weblate detects the CSV format automatically. Compressed uploads retain their
tighter extraction limit. The file must also satisfy
[`TRANSLATION_MAX_SIZE`](https://docs.weblate.org/zh-cn/latest/admin/config.md#std-setting-TRANSLATION_MAX_SIZE).

#### HINT
默认情况下，CSV 格式会自动检测文件编码。这在某些极端情况下可能不可靠，并导致性能下降。请选择文件格式编码以避免这种情况（例如 UTF-8）。

#### WARNING
CSV 格式当前会自动检测 CSV 文件的方言。在某些情况下，自动检测可能会失败，您会得到不同的结果。对于值中包含换行符的 CSV 文件尤其如此。解决方法是建议省略引号字符。

#### SEE ALSO
[CSV](https://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/csv.html)

<a id="multivalue-csv"></a>

## 多值 CSV 文件

#### Versionadded
Added in version 4.13.

CSV文件的这种变体允许每条字符串存储多个翻译。

See [多值格式](https://docs.weblate.org/zh-cn/latest/formats.md#format-multivalue) for how alternatives are handled by quality checks,
automatic fixes, and machine translation.

## 示例文件

示例文件：

```text
Thank you for using Weblate.,Děkujeme za použití Weblate.
```

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

#### 支持的功能

| 文件扩展名                                                                       | `.csv`, `.txt`                   |
|-----------------------------------------------------------------------------|----------------------------------|
| 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)       | `Yes`                            |
| 支持位置 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-location)       | `Yes`                            |
| 支持标记 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-flags)          | `No`                             |
| 额外状态 [ⓘ](https://docs.weblate.org/zh-cn/latest/formats.md#format-states)         | `Needs editing`                  |
| API 标识符                                                                     | `csv`, `csv-multi`, `csv-simple` |
| 支持只读字符串 [ⓘ](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 csv -->

## Weblate 配置

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

|             | 单语 CSV 文件的典型 Weblate [部件配置](https://docs.weblate.org/zh-cn/latest/admin/projects.md#component)   |
|-------------|--------------------------------------------------------------------------------------|
| 文件掩码        | `locale/*.csv`                                                                       |
| 单语言译文模版语言文件 | `locale/en.csv`                                                                      |
| 新语种的翻译模版    | `locale/en.csv`                                                                      |
| 文件格式        | 简单 CSV 文件                                                                            |
