XLIFF¶
備註
Weblate currently supports XLIFF 1.2. XLIFF 2.0 is not supported and is not backwards compatible with XLIFF 1.2.
建立基於 XML 的格式來標準化翻譯文件,但最終它是該領域中 許多標準 之一。
XML Localization Interchange File Format (XLIFF) 通常用作雙語言格式,但 Weblate 也支援其作為單語言格式。
Weblate supports XLIFF in several variants:
- XLIFF 1.2 translation file
Simple XLIFF file where content of the elements is stored as plain text (all XML elements being escaped).
- XLIFF 1.2 with placeables support
Standard XLIFF supporting placeables and other XML elements.
- XLIFF 1.2 with gettext extensions
XLIFF enriched by XLIFF 1.2 Representation Guide for Gettext PO to support plurals.
也參考
XML Localization Interchange File Format (XLIFF) specification, XLIFF 1.2 Representation Guide for Gettext PO, XLIFF on Wikipedia, XLIFF
翻譯狀態¶
文件中的``state`` 屬性在Weblate 中被部分處理並映射為」Needs edit」 (需要編輯)的狀態(如果出現目標的話,後面的狀態用於將字串標記為需要編輯: new `` 、 ``needs-translation
、 needs-adaptation
、 needs-l10n
)。如果應該省略 state
屬性,只要 <target>
元素存在,那麼字串被認為需要翻譯。
如果翻譯字串具有``approved=」yes」``,那麼它還將被導入Weblate 作為」Approved」(同意的),任何其它內容被導入作為」Waiting for review」 (等待複核,這與XLIFF 規範匹配)。
當儲存時,Weblate 如無必要不會新增其它屬性:
state
屬性只在字串標記為需要編輯的情況下新增。approved
屬性只在字串已經被複查的情況下新增。在其它情況下不新增屬性,但在它們出現的情況下更新。
這表示當使用 XLIFF 格式時,強烈推薦打開 Weblate 審查過程,從而能看到並更改字串的審核狀態。
相似地在導入這樣的文件時(在上傳表格中),應該選擇 Processing of strings needing edit 之下的 Import as translated。
也參考
XLIFF 中的空白字元和新行符¶
在 XML 格式中不區分通常類型或量的空白字元。如果想要保留,必須將 xml:space="preserve"
標記新增到字串中。
例如:
<trans-unit id="10" approved="yes">
<source xml:space="preserve">hello</source>
<target xml:space="preserve">Hello, world!
</target>
</trans-unit>
指定翻譯旗標¶
還可以通過使用 weblate-flags
屬性指定附加的翻譯標記(請參見 使用標誌自定義行為)。 Weblate 還理解來自 XLIFF 規範的 maxwidth
和 font
屬性:
<trans-unit id="10" maxwidth="100" size-unit="pixel" font="ubuntu;22;bold">
<source>Hello %s</source>
</trans-unit>
<trans-unit id="20" maxwidth="100" size-unit="char" weblate-flags="c-format">
<source>Hello %s</source>
</trans-unit>
解析 font
屬性用於字體集、尺寸和粗細,上面的示例顯示了全部,儘管只需要字符集。字元集中的任何空白字元被轉換為下劃線,所以 Source Sans Pro
變成 Source_Sans_Pro
,當命名字元集時請記住這些請參見 管理字型)。
String keys¶
Weblate 通過 resname
屬性在它出線的情況下識別 XLIFF 文件中的單元,並退回到 id
(如果出現的話與 file
標籤一起)。
resname
屬性被認為是人類友好的單元識別符,對 Weblate 比 id
更適於顯示。在整個 XLIFF 文件中 resname
具有一致性。這是 Weblate 需要的,並且不被 XLIFF 標準覆蓋——它不在這個屬性上放入任何獨特性限制。
範例檔案¶
Example XLIFF file:
<?xml version='1.0' encoding='UTF-8'?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.1">
<file>
<body>
<trans-unit weblate-flags="c-format, max-length:100">
<source xml:space="preserve">Hello, world!
</source>
</trans-unit>
<trans-unit>
<source xml:space="preserve">Orangutan has %d banana.
</source>
</trans-unit>
<trans-unit>
<source xml:space="preserve">Try Weblate at <https://demo.weblate.org/>!
</source>
</trans-unit>
<trans-unit>
<source>Thank you for using Weblate.</source>
</trans-unit>
</body>
</file>
</xliff>
Weblate 設定組態¶
用於雙語言 XLIFF 的典型 Weblate 組件組態 |
|
---|---|
檔案遮罩 |
|
單語的基底語言檔 |
Empty |
新翻譯的模板 |
|
檔案格式 |
XLIFF 翻譯文件 |
用於單語言 XLIFF 的典型 Weblate 組件組態 |
|
---|---|
檔案遮罩 |
|
單語的基底語言檔 |
|
新翻譯的模板 |
|
檔案格式 |
XLIFF 翻譯文件 |