Task #105647
closedGet rid of "resname" attribute in XLF file
100%
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 2 months 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 2 months 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 2 months 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 2 months ago · Edited
Suggestion:
find . -name \*\.xlf -exec sed -I "" -E 's/<trans-unit([^>]+)id="([^"]+)"([^>]+)>/<trans-unit id="\2">/' {} \;
Updated by Markus Klein about 2 months 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 2 months ago
- Related to Task #89335: Add resname attribute to <trans-unit> tags in XLF added
Updated by Markus Klein about 2 months 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 2 months 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 2 months 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 2 months 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 2 months 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
Updated by Gerrit Code Review about 2 months ago
Patch set 4 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 2 months ago
Patch set 5 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 2 months ago
Patch set 6 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 2 months ago
Patch set 7 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 2 months ago
Patch set 1 for branch 13.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87139
Updated by Anonymous about 2 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset c0578c702d777214ddb6f0364481a4be87c17e72.
Updated by Simon Schaufelberger about 2 months ago · Edited
Xavier Perseguers wrote in #note-5:
Suggestion:
[...]
This command doesn't work for me in bash (ubuntu): sed: invalid Option -- I
This is the working command for me:
find . -name \*\.xlf -exec sed -i -E 's/(<trans-unit[^>]*?)\sresname="[^"]*"/\1/' {} +
Updated by Lina Wolf about 1 month ago
What about original in the file tag, is that one needed?
Updated by Lina Wolf about 1 month ago
https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/5107 Still needs to be reviewed