XLIFF 1.1 および 1.2

注釈

XLIFF 2.0 は XLIFF 1.2 とは異なる形式であり、後方互換性はありません。

XML ベースのファイル形式で、翻訳ファイルを標準化するために作成されましたが、結果的には、この分野の 多くの標準 の 1 つにしかすぎません。

XML Localization Interchange File Format (XLIFF) は、通常はバイリンガルとして使用しますが、Weblate ではモノリンガルとしても対応しています。

Weblate が対応している XLIFF の種類:

XLIFF 1.2 翻訳ファイル

Standard XLIFF file. Placeables handling is controlled by the xliff_placeables ファイル形式パラメータ.

gettext 拡張付きの XLIFF 1.2

複数形に対応するため、XLIFF 1.2 Representation Guide for Gettext PO によって強化された XLIFF。

XLIFF 1.2 with Apple extensions

XLIFF enriched by Apple to support plurals.

翻訳文の状態

ファイルの state 属性は、個別に処理され、Weblate 内の「要修正」状態に分類されます(翻訳対象の文字列が存在する場合に、要修正とフラグが付く状態: new、needs-translation、needs-adaptation、needs-l10n)。state 属性がない場合は、<target> 要素があれば、ただちに翻訳済みとみなします。

翻訳文が、approved="yes" であれば、「承認済み」として Weblate にインポートされますが、それ以外のものは、「査読待ち」(XLIFF 仕様に沿う)としてインポートします。

保存中は、必要がない限り追加されない属性:

  • state 属性は、文字列に「要修正」のフラグが付いている場合にのみ追加される。

  • approved 属性は、文字列が「査読済み」の場合にのみ追加される。

  • その他の場合、属性は追加されないが、存在する場合には更新される。

つまり、XLIFF 形式を使用する場合は、文字列の承認状態を確認して変更できるように、Weblate の査読の強制は必ず有効化してください。

同様に、このようなファイルをインポート(アップロード フォームから)する場合は、要修正の文字列の扱い の中から、要修正として文字列をインポート を選択してください。

XLIFF の空白と改行

Weblate controls how whitespaces are handled with the xml_whitespace_handling ファイル形式パラメータ for XLIFF components:

  • Follow xml:space — honor xml:space attributes in the file (and the XLIFF default when the attribute is missing).

  • Always preserve — keep all whitespace and set xml:space="preserve" on units (Weblate's default for new units).

  • Always normalize — collapse whitespace even when the file sets xml:space="preserve".

To keep newlines or surrounding spaces when following xml:space, mark the string with xml:space="preserve":

    <trans-unit id="10" approved="yes">
        <source xml:space="preserve">hello</source>
        <target xml:space="preserve">Hello, world!
</target>
    </trans-unit>

Placeables in XLIFF

Weblate controls how XML elements inside XLIFF content are handled with the xliff_placeables ファイル形式パラメータ:

  • Plain text — escape XML elements in the content.

  • Placeables — preserve placeables and other XML elements (the default). Tags then appear as placeholders in the editor.

翻訳フラグの指定

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 となります。(参照:fonts)になります。フォントグループに名前を付けるときは、この点に注意してください(参照: フォントの管理)。

文字列キー

Weblate は、XLIFF ファイル内のユニットを、resname 属性が存在する場合はそれによって識別し、なければ id に(存在する場合は file タグとセットで)フォールバックします。

Weblate での表示名として、resname 属性は id よりも ユニットのわかりやすい識別子であると考えています。resname は、XLIFF ファイル全体で一意にしてください。これは、Weblate では必須の条件ですが、XLIFF 標準では一意の制限はありません。

ファイルの例

XLIFF ファイルの設定例:

<?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 &lt;https://demo.weblate.org/&gt;!
</source>
            </trans-unit>
            <trans-unit>
                <source>Thank you for using Weblate.</source>
            </trans-unit>
        </body>
    </file>
</xliff>
対応機能

File extensions

.mxliff, .poxliff, .sdlxliff, .xlf, .xliff

Linguality ⓘ

Both monolingual and bilingual

Supports plural ⓘ

Yes

Supports descriptions ⓘ

Yes

Supports explanation ⓘ

No

Supports context ⓘ

Yes

Supports location ⓘ

Yes

Supports flags ⓘ

Yes

Additional states ⓘ

Approved, Needs editing

API identifier

apple-xliff, poxliff, xliff

Supports read-only strings ⓘ

Yes

Supports removing obsolete strings ⓘ

No

Weblate の設定

バイリンガル XLIFF 用の、標準的な Weblate コンポーネント構成

ファイル マスク

localizations/*.xliff

モノリンガル用の、基礎となる言語ファイル

Empty(空)

新しい翻訳のテンプレート

localizations/en-US.xliff

ファイル形式

XLIFF 翻訳ファイル

モノリンガル XLIFF 用の、標準的な Weblate コンポーネント構成

ファイル マスク

localizations/*.xliff

モノリンガル用の、基礎となる言語ファイル

localizations/en-US.xliff

新しい翻訳のテンプレート

localizations/en-US.xliff

ファイル形式

XLIFF 翻訳ファイル