Closed
Description
In 3 different places in the documentation, we have examples of XLIFF translation files:
- http://symfony.com/doc/current/best_practices/i18n.html
- http://symfony.com/doc/current/book/translation.html
- http://symfony.com/doc/current/components/translation/usage.html
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.