Issue Task Closed

#105647Get rid of "resname" attribute in XLF file

Xavier Perseguers 11/20/24, 10:10 updated 12/02/25, 14:31

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>

(source: https://github.com/xperseguers/t3ext-image_autoresize/blob/master/Resources/Private/Language/locallang.xlf#L6-L8)

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):

clipboard-202411201108-xfbqa.png

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

Reviews 2

Files 1

History 1422

  1. Kevin Appelt commented <span data-processor="relativetime" data-value="2024-11-20T10:33:45+00:00" > 11/20/24, 10:33 </span>

    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.

  2. Christian Kuhn commented <span data-processor="relativetime" data-value="2024-11-20T10:51:35+00:00" > 11/20/24, 10:51 </span>

    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?

  3. Peter Kraume commented <span data-processor="relativetime" data-value="2024-11-20T10:58:21+00:00" > 11/20/24, 10:58 </span>

    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.

  4. Xavier Perseguers commented <span data-processor="relativetime" data-value="2024-11-20T11:24:24+00:00" > 11/20/24, 11:24 </span>

    Suggestion:

    find . -name \*\.xlf -exec sed -I "" -E 's/<trans-unit([^>]+)id="([^"]+)"([^>]+)>/<trans-unit id="\2">/' {} \;
  5. Markus Klein commented <span data-processor="relativetime" data-value="2024-11-20T11:31:12+00:00" > 11/20/24, 11:31 </span>

    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.

  6. Markus Klein commented <span data-processor="relativetime" data-value="2024-11-20T11:34:12+00:00" > 11/20/24, 11:34 </span>

    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

  7. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2024-11-21T10:40:09+00:00" > 11/21/24, 10:40 </span>

    Applied in changeset commit:c0578c702d777214ddb6f0364481a4be87c17e72.

  8. Simon Schaufelberger commented <span data-processor="relativetime" data-value="2024-11-21T21:55:19+00:00" > 11/21/24, 21:55 </span>

    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/' {} +
  9. Lina Wolf commented <span data-processor="relativetime" data-value="2024-11-30T10:11:18+00:00" > 11/30/24, 10:11 </span>

    What about original in the file tag, is that one needed?