Skip to content

[RFC] trans-unit id in XLIFF translation files #6341

Closed
@Mx-Glitter

Description

@Mx-Glitter

In 3 different places in the documentation, we have examples of XLIFF translation files:

In all those cases, the trans-unit id is set to a number. I propose to replace this number by a meaningful string.

Example:

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

changed to

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

Reasoning

  • Ids have no particular meaning, all you need is for them to be distinct in the same file.
  • If two contributors used the same ids, one of them has to renumber its translations to be sure ids are unique (assuming working with a VCS)
  • If a contributor decides to rearrange the translations in a file to group them by category:
    • Either they renumbered all the ids and then it’s a nightmare with VCS.
    • Or the file is not sorted by id anymore, and you don’t know what the next id you have to use for the next translation is.
  • Symfony will now tell you if you have a duplicated source in your file, whereas it was silently overwriting the duplications before.

I can propose a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TranslationhasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions