支持文件类型 (Strings)

.CSV (Strings)

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

文件扩展名 

.csv

API 扩展 

csv

导入 

导出 

复数形式支持 

描述支持 

格式选项 

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

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 文档

格式选项

标识符 

key_index

类型 

integer

上传 

下载 

默认 

[empty]

说明 

包含键名的列索引。列索引从 1 开始。

标识符 

comment_index

类型 

integer

上传 

下载 

默认 

[empty]

说明 

包含键描述的列索引。列索引从 1 开始。

标识符 

tag_column

类型 

integer

上传 

下载 

默认 

[empty]

说明 

包含键标签的列索引。列索引从 1 开始。

标识符 

max_characters_allowed_column

类型 

integer

上传 

下载 

默认 

[empty]

说明 

包含键最大字符数的列索引。列索引从 1 开始。

标识符 

column_separator

类型 

字符串

上传 

下载 

默认 

,

说明 

用于分隔列的字符。

标识符 

quote_char

类型 

字符串

上传 

下载 

默认 

"

说明 

用于引用换行符和列分隔符的字符。

标识符 

header_content_row

类型 

布尔值

上传 

下载 

默认 

false

说明 

指示第一行是否仅包含标题信息并应跳过。

标识符 

enable_pluralization

类型 

布尔值

上传 

下载 

默认 

true

说明 

启用复数键检测。所有匹配的键将作为复数键保留。

标识符 

export_tags

类型 

布尔值

上传 

下载 

默认 

false

说明 

导出标签以及键和翻译。

标识符 

export_max_characters_allowed

类型 

布尔值

上传 

下载 

默认 

false

说明 

导出键 ID 以及键和翻译。

标识符 

custom_metadata_columns

类型 

哈希

上传 

下载 

默认 

[empty]

说明 

需要导入或导出的 自定义元数据 值的 HashMap:

  • 键 = 自定义元数据属性的名称,定义于 Phrase Strings 中。

  • 值 = 属性在导入文件中的列索引(123 等)/ 属性在导出文件中应在的位置。

标识符 

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,
这篇文章有帮助吗?

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.