Task #105647
openGet rid of "resname" attribute in XLF file
0%
Description
According to https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/XliffFormat.html, a trans-unit
node is supposed to have both `id` and `resname` attributes, with the same "key".
From my point of view this is totally useless as I work with XLIFF since TYPO3 4.6 and never did it for my own extensions.
Possible argument is that it's needed for (some) web tool showing that context for the translator.
With Pootle, back then, it was not required.
With Crowdin, it's not required. Proof is with EXT:image_autoresize where I don't have such definitions:
<trans-unit id="saveConfiguration"> <source>Save configuration</source> </trans-unit>
and there's no problem seeing that context on Crowdin (https://crowdin.com/editor/typo3-extension-imageautoresiz/7511/en-fr?view=comfortable&filter=basic&value=3):
Suggestion¶
- Core should not have to worry about tools we don't use ourselves (such as Weblate as I was said it was required there)
- Official contribution documentation should not take care of this either
- I would suggest to get rid of all resname
attributes for the sake of removing unneeded complexity and possible mismatch when working with Core XLIFF files
Files
Updated by Kevin Appelt about 20 hours ago · Edited
Peter Kraume/The localization team asked for feedback:
TBH I really don't care much for this. To avoid issues I run some regex replacements from time to time on my projects.
If anyone is interested:
<trans-unit([^>]+)id="([^"]+)"([^>]+|)> <trans-unit id="$2" resname="$2" approved="yes">
With this, all XLF files always have correct trans-unit attributes. No matter to think about it and just following the documentation.
If resname gets removed, I adjust the replacement and it's fine again.
I do not know how much Weblate (which seems to need it according to the issues description) is used, but it seems actively maintained.
As I do not see much effort to fix all XLF files with the replacement shown above I would tend to say: Let's keep resname to stay compatible.
Updated by Christian Kuhn about 20 hours ago · Edited
Google "weblate resname attribute":
The resname attribute is supposed to be human friendly identifier of the unit making it more suitable for Weblate to display instead of id . The resname has to be unique in the whole XLIFF file.
Our current habit of having identical "id" and "resname" is pointless. Even in weblate, "resname" is an optional additional information, potentially useful when it contains different content than "id".
As far as I can see, "resname" can and should be removed throughout the core. Did I miss something?
Updated by Peter Kraume about 20 hours ago
We discussed the idea in the Localization Team and we also don't see any issues which would block us from removing the resname attribute.
Updated by Xavier Perseguers about 19 hours ago · Edited
Suggestion:
find . -name \*\.xlf -exec sed -I "" -E 's/<trans-unit([^>]+)id="([^"]+)"([^>]+)>/<trans-unit id="\2">/' {} \;
Updated by Markus Klein about 19 hours ago
Can we find in the history why we introduced it in the first place?
I remember we did not add them for fun, there was some good reason.
Updated by Markus Klein about 19 hours ago
- Related to Task #89335: Add resname attribute to <trans-unit> tags in XLF added
Updated by Markus Klein about 19 hours ago
Markus Klein wrote in #note-6:
Can we find in the history why we introduced it in the first place?
I remember we did not add them for fun, there was some good reason.
It was needed for crowdin back then, obviously
Updated by Peter Kraume about 18 hours ago
When we do the change, we also need to update the documentation:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/XliffFormat.html
Updated by Gerrit Code Review about 18 hours ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87096
Updated by Gerrit Code Review about 10 hours ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87096
Updated by Gerrit Code Review about 9 hours ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87096