Description
Description
Right now the translation tool XLIFF exports the same data for the resname
attribute and the <source>
tag:
<trans-unit id="0umDnnC" resname="navbar.home">
<source>navbar.home</source>
<target>__navbar.home</target>
</trans-unit>
But the XLIFF documentation specifies that the <source>
tag should contain the default locale text to be translated, such as:
<trans-unit id="0umDnnC" resname="navbar.home">
<source>Home</source>
<target>__navbar.home</target>
</trans-unit>
Solution
Add a new command/option to sync the source tags of all generated files with the target tags of the default locale.
Example
Before
messages.en.xlf
(default locale)
<trans-unit id="0umDnnC" resname="navbar.home">
<source>navbar.home</source>
<target>Home</target>
</trans-unit>
messages.fr.xlf
(target locale)
<trans-unit id="0umDnnC" resname="navbar.home">
<source>navbar.home</source>
<target>__navbar.home</target>
</trans-unit>
Run our new command
php bin/console translation:update fr --update-source
After
messages.fr.xlf
(target locale)
<trans-unit id="0umDnnC" resname="navbar.home">
<source>Home</source>
<target>__navbar.home</target>
</trans-unit>
Conclusion
This modification should be helpful for localization team that use software where they can see both the resname
key and the original source. In most translation software you can translate the source automatically (i.e. with Deepl) and right now having the keys inside the source is unhelpful (and not compliant to the XLIFF format).
Thanks!