|
文件扩展名 |
.csv |
|
API 扩展 |
csv |
|
导入 |
是 |
|
导出 |
是 |
|
复数形式支持 |
是 |
|
描述支持 |
是 |
|
格式选项 这些选项可在文件上传和/或下载时指定。根据上传/下载方法(API、CLI、Repo 同步等),它们可以在查询参数 |
key_index comment_index tag_column max_characters_allowed_column column_separator quote_char header_content_row enable_pluralization export_tags export_max_characters_allowed custom_metadata_columns export_key_id key_id_column |
CSV(逗号分隔值)是一种主要用于各种应用程序和程序中数据传输的流行文件格式。在 CSV 文件中,每一行都是一条数据记录。每条记录由几个用逗号分隔的字段组成。 导入前,请确保 CSV 文件中单行包含三个字段,分别代表原文/源语内容、翻译和注释(可选)。
locale_mapping 参数(类型为 hashmap)是必需的,用于指定文档中的哪一列对应于每个区域。有关示例,请参阅 配置文件示例 和上传的 API 文档。
格式选项
|
标识符 |
custom_metadata_columns |
|
类型 |
哈希 |
|
上传 |
是 |
|
下载 |
是 |
|
默认 |
[empty] |
|
说明 |
需要导入或导出的 自定义元数据 值的 HashMap:
|
|
标识符 |
export_key_id |
|
类型 |
布尔值 |
|
上传 |
否 |
|
下载 |
是 |
|
默认 |
false |
|
说明 |
导出键字符限制以及键和翻译。 |
|
标识符 |
key_id_column |
|
类型 |
integer |
|
上传 |
否 |
|
下载 |
是 |
|
默认 |
[empty] |
|
说明 |
包含键 ID 的列索引。列索引从 1 开始。 |
代码示例
boolean_key,"--- true " 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 a line-break." nested.deeply.key,"Wow, this key is nested even deeper." nested.key,This key is nested inside a namespace. null_translation, pluralized_key.one, "Only one kitten found." pluralized_key.other,"Wow, you have %s kittens!" pluralized_key.zero,"You have no kittens." 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)
文件结构
典型的 .CSV 文件结构:
1 (Key column), 2 (Translation column), 3 (Comment column) app_title, My Software Project, This is the main title apples.zero, one apple, my comment ...
配置示例
用于 .CSV 文件的 .phrase.yml 的 push 部分示例:
push:
sources:
- file: "./multi.csv"
params:
update_translations: true
locale_mapping:
en: 2
de: 3
format_options:
comment_index: 4
tag_column: 5
此格式使用命名的类别来标识键的不同复数形式。以下类别作为复数形式保留:
.zero | .one | .two | .few | .many | .other
正确识别、保留和标记复数键的名称示例:
-
inbox.messages.notification.one
-
inbox.messages.notification.other
文件应遵循此结构:
1 (Key column), 2 (Translation column), 3 (Comment column) messages.zero, No messages received, messages.one, One message received, messages.other, %s messages received,