Contributed by
Jérémy Derussé
in #10939.

Internationalization is one of the toughest features to implement in a web application. Specifically, translating contents is a challenging task that requires not only an advanced knowledge of the subject to translate, but as much contextual information as possible.

This recent conversation on the Symfony repository is a good example of the challenges that translators face when trying to adhere as closely as possible to the original meaning.

Since good translations are all about context information, Symfony 2.6 will add support for adding <note> elements to the XLIFF files. According to the XLIFF specification:

The <note> element is used to add localization-related comments to the XLIFF document. The content of <note> may include instructions from developers about how to handle the <source>, comments from the translator about the translation, or any comment from anyone involved in processing the XLIFF file.

The previous versions of Symfony removed the <note> nodes from XLIFF files when executing the translation:update command. Now, this command will preserve the <note> nodes alongside any optional from and priority attributes. The following is an example of a complex XLIFF file supported in Symfony 2.6:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
    <file source-language="en" target-language=".." datatype="plaintext">
        <body>
            <trans-unit id="1">
                <source>Update</source>
                <target>...</target>
                <note>
                    This should be translated as a verb (e.g. "Update your
                    contents"). This text is typically displayed as the
                    button label.
                </note>
            </trans-unit>

            <trans-unit id="2">
                <source>Update</source>
                <target>...</target>
                <note from="QA department" priority="1">
                    Beware that this translation is the one that causes most
                    errors during the QA tests.
                </note>
                <note priority="2">
                    This should be translated as a noun (e.g. "Information Update").
                    This text is typically displayed as part of a heading.
                </note>
            </trans-unit>
        </body>
    </file>
</xliff>