<a id="xliff"></a>

# XLIFF 1.1 and 1.2

<a id="index-0"></a>

#### NOTE
[XLIFF 2.0](https://docs.weblate.org/fr/latest/formats/xliff2.md) is a different format and is not backwards compatible with XLIFF 1.2.

Format basé sur XML créé pour normaliser les fichiers de traduction, mais en fin de compte, ce n’est qu’une des trop [nombreuses normes](https://xkcd.com/927/) du domaine.

XML Localization Interchange File Format (XLIFF) est généralement utilisé comme fichier bilingue, mais Weblate prend également en charge la version monolingue.

Weblate supporte le format XLIFF dans plusieurs variantes :

Fichier de traduction XLIFF 1.2
: Standard XLIFF file. Placeables handling is controlled by the
  `xliff_placeables` [Paramètres du format de fichier](https://docs.weblate.org/fr/latest/formats.md#file-format-params).

XLIFF 1.2 with gettext extensions
: XLIFF enriched by [XLIFF 1.2 Representation Guide for Gettext PO](https://docs.oasis-open.org/xliff/v1.2/xliff-profile-po/xliff-profile-po-1.2-cd02.html) to support plurals.

XLIFF 1.2 with Apple extensions
: XLIFF enriched by Apple to support plurals.

#### SEE ALSO
* [XML Localization Interchange File Format (XLIFF)](https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html) specification
* [XLIFF 1.2 Representation Guide for Gettext PO](https://docs.oasis-open.org/xliff/v1.2/xliff-profile-po/xliff-profile-po-1.2-cd02.html)
* [XLIFF on Wikipedia](https://en.wikipedia.org/wiki/XLIFF)
* [XLIFF](https://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/xliff.html)

## États de traduction

The `state` attribute in the file is partially processed and mapped to the
« Needs edit » state in Weblate (the following states are used to flag the string as
needing edit if there is a target present: `new`, `needs-translation`,
`needs-adaptation`, `needs-l10n`). Should the `state` attribute be
missing, a string is considered translated as soon as a `<target>` element
exists.

If the translation string has `approved="yes"`, it will also be imported into Weblate
as « Approved », anything else will be imported as « Waiting for review » (which matches the
XLIFF specification).

While saving, Weblate doesn’t add those attributes unless necessary:

* The `state` attribute is only added in case string is marked as needing edit.
* The `approved` attribute is only added in case string has been reviewed.
* In other cases the attributes are not added, but they are updated in case they are present.

That means that when using the XLIFF format, it is strongly recommended to turn on the
Weblate review process, in order to see and change the approved state of strings.

Similarly upon importing such files (in the upload form), you should choose
Import as translated under
Processing of strings needing edit.

#### SEE ALSO
[Relecteurs dédiés](https://docs.weblate.org/fr/latest/workflows.md#reviews)

## Whitespace and newlines in XLIFF

Use the `xml_utf8_bom`, `xml_encoding_case`, and `xml_final_newline`
[Paramètres du format de fichier](https://docs.weblate.org/fr/latest/formats.md#file-format-params) to control the byte order mark, declaration encoding
case, and final newline when writing XLIFF files.

Weblate controls how whitespaces are handled with the `xml_whitespace_handling`
[Paramètres du format de fichier](https://docs.weblate.org/fr/latest/formats.md#file-format-params) 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"`:

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

#### SEE ALSO
[Paramètres du format de fichier](https://docs.weblate.org/fr/latest/formats.md#file-format-params)

## Placeables in XLIFF

Weblate controls how XML elements inside XLIFF content are handled with the
`xliff_placeables` [Paramètres du format de fichier](https://docs.weblate.org/fr/latest/formats.md#file-format-params):

* 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.

#### SEE ALSO
[Paramètres du format de fichier](https://docs.weblate.org/fr/latest/formats.md#file-format-params)

<a id="xliff-flags"></a>

## Specifying translation flags

You can specify additional translation flags (see [Personnaliser le comportement en utilisant des drapeaux](https://docs.weblate.org/fr/latest/admin/checks.md#custom-checks)) by
using the `weblate-flags` attribute. Weblate also understands `maxwidth` and `font`
attributes from the XLIFF specification:

```xml
<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>
```

The `font` attribute is parsed for font family, size and weight, the above
example shows all of that, though only font family is required. Any whitespace
in the font family is converted to underscore, so `Source Sans Pro` becomes
`Source_Sans_Pro`, please keep that in mind when naming the font group (see
[Gestion des polices](https://docs.weblate.org/fr/latest/admin/checks.md#fonts)).

#### SEE ALSO
* [font attribute in XLIFF 1.2](https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#font)
* [maxwidth attribute in XLIFF 1.2](https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#maxwidth)

## Clés de chaîne

Weblate identifies the units in the XLIFF file by `resname` attribute in case
it is present and falls back to `id` (together with `file` tag if present).

The `resname` attribute is supposed to be human friendly identifier of the
unit making it more suitable for Weblate to display instead of `id`. The
`resname` has to be unique in the whole XLIFF file. This is required by
Weblate and is not covered by the XLIFF standard - it does not put any
uniqueness restrictions on this attribute.

## Fichiers d’exemples

Exemple de fichier XLIFF :

```xml
<?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>
```

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

#### Fonctionnalités prises en charge

| File extensions                                                                                      | `.mxliff`, `.poxliff`, `.sdlxliff`, `.xlf`, `.xliff`   |
|------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
| Linguality [ⓘ](https://docs.weblate.org/fr/latest/formats.md#bimono)                                   | Both monolingual and bilingual                         |
| Supports plural [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-plurals)                      | `Yes`                                                  |
| Supports descriptions [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-description)            | `Yes`                                                  |
| Supports explanation [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-explanation)             | `No`                                                   |
| Supports context [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-context)                     | `Yes`                                                  |
| Supports location [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-location)                   | `Yes`                                                  |
| Supports flags [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-flags)                         | `Yes`                                                  |
| Additional states [ⓘ](https://docs.weblate.org/fr/latest/formats.md#format-states)                     | `Approved`, `Needs editing`                            |
| API identifier                                                                                       | `apple-xliff`, `poxliff`, `xliff`                      |
| Supports read-only strings [ⓘ](https://docs.weblate.org/fr/latest/formats.md#read-only-strings)        | `Yes`                                                  |
| Supports removing obsolete strings [ⓘ](https://docs.weblate.org/fr/latest/formats.md#obsolete-strings) | `No`                                                   |
<!-- AUTOGENERATED END: format-features xliff -->

## Configuration Weblate

|                                       | Typical Weblate [Configuration des composants](https://docs.weblate.org/fr/latest/admin/projects.md#component) for bilingual XLIFF   |
|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| Masque de fichier                     | `localizations/*.xliff`                                                                                                     |
| Fichier de langue de base mono-langue | Vide                                                                                                                        |
| Modèle pour les nouvelles traductions | `localizations/en-US.xliff`                                                                                                 |
| Format de fichier                     | XLIFF Translation File                                                                                                      |

|                                       | Typical Weblate [Configuration des composants](https://docs.weblate.org/fr/latest/admin/projects.md#component) for monolingual XLIFF   |
|---------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| Masque de fichier                     | `localizations/*.xliff`                                                                                                       |
| Fichier de langue de base mono-langue | `localizations/en-US.xliff`                                                                                                   |
| Modèle pour les nouvelles traductions | `localizations/en-US.xliff`                                                                                                   |
| Format de fichier                     | XLIFF Translation File                                                                                                        |
