支持文件类型 (Strings)

.TXT (Strings)

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

文件扩展名 

.txt, .tsv

API 扩展 

.txt, .tsv

导入 

导出 

复数形式支持 

描述支持 

格式选项 

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

key_index

comment_index: 4

tag_column: 5

max_characters_allowed_column

column_separator: ";"

quote_char

header_content_row

enable_pluralization

export_tags

export_max_characters_allowed

custom_metadata_columns

TXT 存储纯文本信息,不包含任何嵌入式格式选项,如粗体、斜体或图像。

locale_mapping 参数(类型为哈希映射)是必需的,用于指定文档中哪一列对应于每个区域。有关示例,请参阅 configuration file example 以及用于上传的 API documentation

格式选项

标识符 

key_index

类型 

integer

上传 

下载 

默认 

[empty]

说明 

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

标识符 

comment_index: 4

类型 

integer

上传 

下载 

默认 

[empty]

说明 

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

标识符 

tag_column: 5

类型 

integer

上传 

下载 

默认 

[empty]

说明 

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

标识符 

max_characters_allowed_column

类型 

integer

上传 

下载 

默认 

[empty]

说明 

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

标识符 

column_separator: ";"

类型 

字符串

上传 

下载 

默认 

\t

说明 

用于分隔列的字符。

标识符 

quote_char

类型 

字符串

上传 

下载 

默认 

"

说明 

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

标识符 

header_content_row

类型 

布尔值

上传 

下载 

默认 

false

说明 

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

标识符 

enable_pluralization

类型 

布尔值

上传 

下载 

默认 

true

说明 

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

标识符 

export_tags

类型 

布尔值

上传 

下载 

默认 

false

说明 

导出标记以及键和翻译。

标识符 

export_max_characters_allowed

类型 

布尔值

上传 

下载 

默认 

false

说明 

导出键字符限制以及键和翻译。

标识符 

custom_metadata_columns

类型 

哈希

上传 

下载 

默认 

[empty]

说明 

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

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

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

代码示例

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    此键嵌套在命名空间内。
null_translation    
pluralized_key.one    "仅找到一只小猫。"
pluralized_key.other    "哇,你有 %s 只小猫!"
pluralized_key.zero    "你没有小猫。"
sample_collection    "---
- first item
- second item
- third item
"
simple_key    只是一个带有简单消息的简单键。
unverified_key    此翻译尚未验证,正在等待验证。(在某些格式中,我们也会导出此状态)

文件结构

典型的 .TXT 文件结构:

1 (键列)    2 (翻译列)    3 (备注列)
app_title    我的软件项目    这是主标题
apples.zero    一个苹果    我的备注
...

配置示例

针对 .CSV 文件的 .phrase.yml 的 push 部分示例:

push:
    sources:
        - file: "./multi.txt"
          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 (键列)    2 (翻译列)    3 (备注列)
messages.zero    未收到消息,
messages.one    收到一条消息,
messages.other    收到 %s 条消息,
这篇文章有帮助吗?

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.