Pierre-Antoine Guillaume
Pierre-Antoine Guillaume

Reputation: 1126

How to translate key-indexed XLIFF files in multiples languages?

In the process of internationalizing a web application, we have some XLIFF files in french and we are going to translate them in two other languages.

We are going to transition to symfony in the long run (6 month), so that is our target ; and they recommand using instead of real sentences as keys : https://symfony.com/doc/5/best_practices.html

So our files look like that:

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" target-language="fr" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="translation">
                <source>trans</source>
                <target>traduction</target>
            </trans-unit>
        </body>
    </file>
</xliff>

and hopefuly, our end files will end up like that :

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" target-language="es" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="translation">
                <source>trans</source>
                <target>traduccion</target>
            </trans-unit>
        </body>
    </file>
</xliff>

With symfony's translation-contracts, I end up with something like that :

<?php
// ...
echo $translator->trans('trans');
// traduction

I have all my PHP working.

It is practical, for developers, to use keys instead of sentences, but it seems like it does not go well with the XLIFF standard which asks two languages per file.

Standard software assist translation from source language to target language in a single file, and this goes in conflict with symfony best-practice, and both are right to advice doing so.

How do you assist the translation process from key-indexed XLIFF files?

Upvotes: 0

Views: 515

Answers (1)

Alexander Dimitrov
Alexander Dimitrov

Reputation: 974

Personally I use yaml for translations, but I don’t have complicated translations anyway.

You can use always the source language as en and the source of every translations should be the key which the developers should use.

Upvotes: 0

Related Questions