支持文件类型 (Strings)

.XLIFF - XML Localization Interchange File Format (Strings)

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

文件扩展名 

.xlf, .xliff

API 扩展 

xlf

导入 

导出 

复数形式支持 

描述支持 

格式选项 

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

enclose_in_cdata

include_translation_state

indent_size

indent_style

ignore_source_translations

ignore_target_translations

export_key_id_as_resname

export_key_name_hash_as_extradata

override_file_language

strip_placeholder_delimiters

delimit_placeholders

翻译行业中使用最广泛的文件格式。它可以被视为源文件的镜像,将源内容分解为存储在标签中的各种段落(例如 <trans-unit>, <seg-source>)。 

XLIFF 是基于 XML 的,并遵循基本的 XML 约定,如有效性和良好的格式。在翻译之前,始终通过将文件扩展名从 .xliff (.xlf) 更改为 .xml 并在网页浏览器中打开它来进行完整性检查。如果文件有效,将呈现良好组织的文档结构;如果无效,则将无法呈现或显示错误消息。

XLIFF 已更新为 XLIFF 2.0。它类似于更广泛使用的 XLIFF,但是一种不同的文件格式,通常与 XLIFF 不兼容。

Xcode 可以将本地化字符串打包为行业标准的 XLIFF 格式,以便与 Phrase 一起发送进行本地化。

格式选项

标识符 

enclose_in_cdata

类型 

布尔值

上传 

下载 

默认 

false

说明 

将包含 html 标签的翻译封装在 CDATA 中。如果禁用,不支持的 HTML 实体将被替换为其解码值。例如:

  • &pound; 被替换为 £

  • &trade; 被替换为

标识符 

include_translation_state

类型 

布尔值

上传 

下载 

默认 

false

说明 

包含目标区域的翻译状态。每个 <target> 标签将获得一个 状态 属性,可以是以下之一:, 已签署, 已翻译

标识符

indent_size

类型 

integer

上传 

下载 

默认 

4

说明 

指定缩进字符的数量

标识符

indent_style

类型 

字符串

上传 

下载 

默认 

空间

说明 

指定缩进字符。允许的值是 spacetab

标识符 

ignore_source_translations

类型 

布尔值

上传 

下载 

默认 

false

说明 

在上传期间忽略文件中的源翻译(以避免意外的源语言更新)

标识符 

ignore_target_translations

类型 

布尔值

上传 

下载 

默认 

false

说明 

在上传期间忽略文件中的目标翻译(以避免意外的源语言更新)

标识符 

export_key_id_as_resname

类型 

布尔值

上传 

下载 

默认 

false

说明 

将 Key ID 导出为 resname 属性。

标识符 

export_key_name_hash_as_extradata

类型 

布尔值

上传 

下载 

默认 

false

说明 

将 Key Name 哈希导出为 extradata 属性。

标识符 

override_file_language

类型 

布尔值

上传 

下载 

默认 

false

说明 

此文件格式通常在文件本身包含语言信息。使用此选项覆盖您指定的语言。

标识符 

strip_placeholder_delimiters

类型 

布尔值

上传 

下载 

默认 

false

说明 

从翻译中移除 <ph> 标签

标识符 

delimit_placeholders

类型 

布尔值

上传 

下载 

默认 

false

说明 

将翻译占位符包裹在 <ph> 标签中。必须在项目设置中定义有效的占位符样式。

代码示例

<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
  <file original="global" datatype="plaintext" source-language="de-DE" target-language="en-GB">
    <body>
      <trans-unit id="boolean_key">
        <source xml:lang="de-DE">--- true
</source>
        <target xml:lang="en-GB">--- true
</target>
      </trans-unit>
      <trans-unit id="empty_string_translation">
        <source xml:lang="de-DE"/>
        <target xml:lang="en-GB"/>
      </trans-unit>
      <trans-unit id="key_with_description">
        <source xml:lang="de-DE">看看这个!这个键有一个描述!</source>
        <target xml:lang="en-GB">检查一下!This key has a description!(至少在某些格式中)</target>
        <note>这是这个键的惊人描述!</note>
      </trans-unit>
      <trans-unit id="key_with_line-break">
        <source xml:lang="de-DE">Diese Übersetzung hat
<einen Zeilenumbruch.</source>
        <target xml:lang="en-GB">这个翻译包含</target>
a line-break.</target>
      </trans-unit>
      <trans-unit id="nested.deeply.key">
        <source xml:lang="de-DE">我是一把深层嵌套的键。</source>
        <target xml:lang="en-GB">我是一把深层嵌套的键。</target>
      </trans-unit>
      <trans-unit id="nested.key">
        <source xml:lang="de-DE">这个键嵌套在一个命名空间内。</source>
        <target xml:lang="en-GB">这个键嵌套在一个命名空间内。</target>
      </trans-unit>
      <trans-unit id="null_translation">
        <source xml:lang="de-DE"/>
        <target xml:lang="en-GB"/>
      </trans-unit>
      <trans-unit id="sample_collection">
        <source xml:lang="de-DE">---
- 第一个条目
- 第二个条目
</source>
        <target xml:lang="en-GB">---
- first item
- second item
- third item
</target>
      </trans-unit>
      <trans-unit id="simple_key">
        <source xml:lang="de-DE">Einfacher Schlüssel, einfache Nachricht, so einfach</source>
        <target xml:lang="en-GB">简单的键,简单的消息,如此简单。</target>
      </trans-unit>
      <trans-unit id="unverified_key">
        <source xml:lang="de-DE">这个翻译尚未验证,正在等待!</source>
        <target xml:lang="en-GB">这个翻译尚未验证,正在等待。</target>(在某些格式中,我们也导出此状态)</target>
      </trans-unit>
    </body>
  </file>
</xliff>

复数形式

复数键使用以下语法导出:

<trans-unit id="plural_key">
  <source xml:lang="zh">{"one":"一把椅子","other":"{nrOfChairs} 把椅子","zero":"没有椅子"}</source>
  <target xml:lang="de">{"one":"ein Stuhl","other":"{nrOfChairs} Stühle","zero":"keine Stühle"}</target>
</trans-unit>
这篇文章有帮助吗?

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.