支持的文件格式#

Weblate 支持各种各样的翻译格式。每种格式之间有略微的不同,提供不同的功能集。

提示

为您的应用程序选择文件格式时,最好在您使用的工具包/平台中保留一些支持完善的格式。这样,您的翻译人员可以额外使用他们习惯使用的任何工具,并且更有可能为您的项目作贡献。

自动检测#

Weblate 尝试在 添加翻译项目和部件 过程中检测文件格式。对于同一序列化格式的不同变体或文件编码,检测可能出错(JSON, YAML, properties),因此在创建部件前请验证 文件格式 正确无误。

翻译类型功能#

所有受支持格式的功能#

格式

语言能力 [1]

复数 [2]

描述 [3]

上下文 [4]

位置 [5]

标记 [8]

更多状态 [6]

GNU gettext

双语

支持

支持

支持

支持

支持 [9]

需要编辑

单语 gettext

单语

支持

支持

支持

支持

支持 [9]

需要编辑

XLIFF

二者

支持

支持

支持

支持

支持

需要编辑、已核准

Java 属性

二者

不支持

支持

不支持

不支持

不支持

mi18n lang 文件

单语

不支持

支持

不支持

不支持

不支持

GWT 属性

单语

支持

支持

不支持

不支持

不支持

Joomla 翻译

单语

不支持

支持

不支持

支持

不支持

Qt Linguist .ts

二者

支持

支持

不支持

支持

支持

需要编辑

Android 字符串资源

单语

支持

支持 [7]

不支持

不支持

支持

苹果 iOS 字符串

二者

不支持

支持

不支持

不支持

不支持

PHP 字符串

单语

不支持 [10]

支持

不支持

不支持

不支持

JSON 文件

单语

不支持

不支持

不支持

不支持

不支持

i18next JSON 文件

单语

支持

不支持

不支持

不支持

不支持

go-i18n JSON 文件

单语

支持

支持

不支持

不支持

不支持

gotext JSON 文件

单语

支持

支持

不支持

支持

不支持

ARB 文件

单语

支持

支持

不支持

不支持

不支持

WebExtension JSON

单语

支持

支持

不支持

不支持

不支持

RESX .NET 资源文件

单语

不支持

支持

不支持

不支持

支持

ResourceDictionary 文件

单语

不支持

不支持

不支持

不支持

支持

CSV 文件

二者

不支持

支持

支持

支持

不支持

需要编辑

YAML 文件

单语

不支持

不支持

不支持

不支持

不支持

Ruby YAML 文件

单语

支持

不支持

不支持

不支持

不支持

DTD 文件

单语

不支持

不支持

不支持

不支持

不支持

Flat XML 文件

单语

不支持

不支持

不支持

不支持

支持

Windows RC 文件

单语

不支持

支持

不支持

不支持

不支持

Excel Open XML

单语

不支持

支持

支持

支持

不支持

需要编辑

应用商店元数据文件

单语

不支持

不支持

不支持

不支持

不支持

字幕文件

单语

不支持

不支持

不支持

支持

不支持

HTML 文件

单语

不支持

不支持

不支持

不支持

不支持

OpenDocument 格式

单语

不支持

不支持

不支持

不支持

不支持

IDML 格式

单语

不支持

不支持

不支持

不支持

不支持

INI 翻译

单语

不支持

不支持

不支持

不支持

不支持

Inno Setup INI 翻译

单语

不支持

不支持

不支持

不支持

不支持

TermBase eXchange 格式

双语

不支持

支持

不支持

不支持

支持

文本文件

单语

不支持

不支持

不支持

不支持

不支持

Stringsdict 格式

单语

支持

不支持

不支持

不支持

不支持

Fluent 格式

单语

不支持 [11]

支持

不支持

不支持

不支持

双语和单语格式#

支持 单语 和 双语 格式。双语格式在单个文件中存储两种语言文本——原文和译文(典型示例是 GNU gettextXLIFF苹果 iOS 字符串 字符串)。另一方面,单语格式通过 ID 识别字符串,每个语言文件仅包含那些语言到任何给定语言(典型为 Android 字符串资源)的映射。两种变体都使用某些文件格式,请参见下面的详细说明。

为了正确使用单语文件,Weblate 需要访问一个包含要翻译的字符串及其原文的完整列表的文件——该文件在 Weblate 中被称为 单语言译文模版语言文件,尽管命名上和你的叫法可能会有所不同。

另外,可以利用 中间语言文件 扩展此工作流程,以包括开发人员提供的字符串,但不要在最终的字符串中使用。

String states#

Many file formats only differentiate “Untranslated” and “Translated” strings. With some formats it is possible to store more fine-grained state information, such as “Needs editing” or “Approved”.

Source string description#

源字符串描述可用于传递要翻译的字符串的附加信息。

Several formats have native support for providing additional info to translators (for example XLIFF, GNU gettext, WebExtension JSON, CSV 文件, Excel Open XML, Qt Linguist .ts, go-i18n JSON 文件, gotext JSON 文件, ARB 文件, RESX .NET 资源文件). Many other formats extract closest comment as source string description.

解释#

The 解释 on strings can be stored and parsed from a few file formats.

Currently supported only in TermBase eXchange 格式.

Source string location#

字符串在源代码中的位置可能会帮助经验丰富的译者弄清楚字符串是如何使用的。

This information is typically available in bilingual formats where strings are extracted from the source code using tools. For example GNU gettext and Qt Linguist .ts.

翻译标记#

翻译标志允许自定义 Weblate 行为。某些格式支持在翻译文件中定义它们(您始终可以在 Weblate 界面中定义它们,请参阅 使用标记定制行为 )。

这个功能是以 GNU gettext 中的标志为模型。

此外,对于所有基于 XML 的格式,标记是从非标准属性 weblate-flags 中提取的。而且还通过 XLIFF 标准中定义的 maxwidth 属性 支持了 max-length:N ,请参阅 指定翻译标记

Context#

Context is used to differentiate identical strings in a bilingual format used in different scopes (for example Sun can be used as an abbreviated name of the day “Sunday” or as the name of our closest star).

For monolingual formats the string identifier (often called key) can serve the same purpose and additional context is not necessary.

复数字符串#

复数形式对于正确定位具有变量计数的字符串是必需的。这些规则取决于目标语言,许多格式都遵循 CLDR 规范。

提示

复数字符串也需要应用程序框架的适当支持。选择平台的原生格式,例如 GNU gettextAndroid 字符串资源Stringsdict 格式

只读字符串#

在 3.10 版本加入.

翻译文件中的只读字符串将被包含在 Weblate 中,但不能在 Weblate 中对其进行编辑。只有少数格式(XLIFFAndroid 字符串资源)原生支持此功能,但可以通过添加 read-only 标记在其他格式中进行模拟,请参阅 使用标记定制行为

支持其他格式#

translate-toolkit 支持的大多数支持序列化的格式都可以轻松支持,但它们(尚未)接受任何测试。在大多数情况下,Weblate 需要一些薄层来隐藏不同 translate-toolkit 存储的行为差异。

要添加对新格式的支持,首选方法是首先在 translate-toolkit 中实现对它的支持。