支持文件类型 (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文件的每一行有三个字段,分别表示源内容、翻译和评论(可选)。

区域映射参数(类型为哈希映射)是必需的,以指定文档中每个区域对应的列。有关示例,请参见配置文件示例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中定义。

  • 值 = 列索引 (1, 2, 3等),其中属性在导入的文件中/属性应在导出的文件中。

标识符 

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!(至少在某些格式中),这是这个键的惊人描述!
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.(在某些格式中,我们也导出这个状态)

文件结构

典型的.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:
    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.