# XLIFF 2.0

#### Versionadded
在 5.15 版被加入.

#### Versionchanged
在 2026.9 版的變更.

#### NOTE
此格式的支援尚在開發中。某些功能可能尚未提供，行為也可能隨發行版本而改變。歡迎提供測試意見。

#### NOTE
[XLIFF 1.1 與 1.2](https://docs.weblate.org/zh-tw/latest/formats/xliff.md) 是不同的格式，不相容 XLIFF 2.0。

建立基於 XML 的格式來標準化翻譯檔案，但最終它是該領域中 [許多標準](https://xkcd.com/927/) 之一。

XML Localization Interchange File Format (XLIFF) 2.0 目前僅支援雙語格式。

Weblate 將 XLIFF 2.0 支援為單一檔案格式。可透過 `xliff_placeables` [檔案格式參數](https://docs.weblate.org/zh-tw/latest/formats.md#file-format-params) 控制 placeables 的處理方式：

* 純文字 — 跳脫內容中的 XML 元素（既有 XLIFF 2.0 組件的歷史預設值）。
* Placeables — 保留 placeables 和其他 XML 元素（新組件的預設值）。這些標籤會以佔位符的形式顯示在編輯器中。

#### SEE ALSO
* [XML 在地化交換檔案格式 (XLIFF) 2.0](https://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html) 規範
* [維基百科上的 XLIFF](https://en.wikipedia.org/wiki/XLIFF)
* [XLIFF](https://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/xliff.html)
* [檔案格式參數](https://docs.weblate.org/zh-tw/latest/formats.md#file-format-params)

## 範例檔案

典型 XLIFF 檔案：

```xml
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="cs">
  <file id="translation">
    <unit id="hello">
      <segment>
        <source xml:space="preserve">Hello, world!
</source>
        <target xml:space="preserve">Ahoj světe!
</target>
      </segment>
    </unit>
    <unit id="orangutan">
      <segment>
        <source xml:space="preserve">Orangutan has %d banana.
</source>
      </segment>
    </unit>
    <unit id="weblate">
      <segment>
        <source xml:space="preserve">Try Weblate at &lt;https://demo.weblate.org/&gt;!
</source>
      </segment>
    </unit>
    <unit id="thanks">
      <segment>
        <source>Thank you for using Weblate.</source>
      </segment>
    </unit>
  </file>
</xliff>
```

<!-- AUTOGENERATED START: format-features xliff2 -->
<!-- This section is automatically generated by `./manage.py list_format_features`. Do not edit manually. -->

#### 支援的功能

| 副檔名                                                                            | `.xlf`, `.xliff`   |
|--------------------------------------------------------------------------------|--------------------|
| 語言能力 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#bimono)                   | 雙語言                |
| 支援複數 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-plurals)           | `Yes`              |
| 支援描述 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-description)       | `Yes`              |
| 支援解釋 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-explanation)       | `No`               |
| 支援情境 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-context)           | `Yes`              |
| 支援位置 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-location)          | `Yes`              |
| 支援旗標 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-flags)             | `Yes`              |
| 額外狀態 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#format-states)            | `已核准`, `需要編輯`      |
| API 辨識碼                                                                        | `xliff2`           |
| 支援唯讀字串 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#read-only-strings)      | `Yes`              |
| 支援移除已不再使用的字串 [ⓘ](https://docs.weblate.org/zh-tw/latest/formats.md#obsolete-strings) | `No`               |
<!-- AUTOGENERATED END: format-features xliff2 -->

## Weblate 設定

|           | 典型的 Weblate [組件設定](https://docs.weblate.org/zh-tw/latest/admin/projects.md#component)   |
|-----------|-----------------------------------------------------------------------------|
| 檔案遮罩      | `localizations/*.xliff`                                                     |
| 單語言基底語言檔案 | 空白                                                                          |
| 新翻譯的範本    | `localizations/en-US.xliff`                                                 |
| 檔案格式      | XLIFF 2.0 翻譯檔案                                                              |
