weblate icon indicating copy to clipboard operation
weblate copied to clipboard

Add support for Apple XLIFF

Open bryceco opened this issue 10 months ago • 5 comments

Describe the issue

For my app I'm uploading XLIFF files generated by Xcode (XLIFF 1.2). The strings file includes plural forms for "one", "few", "many" and "other". However when viewing the strings on Weblate users only see entries for "one" and "other". Similarly when I download a PO of the strings the "few" and "many" strings are missing. When I download the XLIFF file using "File in original format as translated in the repository" XLIFF 1.2 with placeables support the plurals are there.

<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
  <file original="Base.lproj/MainStoryboard.storyboard" source-language="en" target-language="ru" datatype="plaintext">
    <header>
      <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.3" build-num="15E204a"/>
    </header>
    <body>
      <trans-unit id=" (%d members)&#10;|==|plural.few" xml:space="preserve">
        <source> (%d members)</source>
        <target state="translated"> (%d элемета)</target>
        <note/>
      </trans-unit>
      <trans-unit id=" (%d members)&#10;|==|plural.many" xml:space="preserve">
        <source> (%d members)</source>
        <target state="translated"> (%d элементов)</target>
        <note/>
      </trans-unit>
      <trans-unit id=" (%d members)&#10;|==|plural.one" xml:space="preserve">
        <source> (%d member)</source>
        <target state="translated"> (%d элемент)</target>
        <note/>
      </trans-unit>
      <trans-unit id=" (%d members)&#10;|==|plural.other" xml:space="preserve">
        <source> (%d members)</source>
        <target state="translated"> (%d элементов)</target>
        <note/>
      </trans-unit>
    </body>
  </file>
</xliff>

I already tried

  • [X] I've read and searched the documentation.
  • [X] I've searched for similar filed issues in this repository.

Steps to reproduce the behavior

  1. Verify that the translation file linked above contains "few"/"many" plurals.
  2. See that the equivalent strings in the Weblate web interface are missing.

Expected behavior

No response

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

weblate.org service

Weblate versions

No response

Weblate deploy checks

No response

Additional context

No response

bryceco avatar Apr 24 '24 22:04 bryceco

Weblate doesn't yet support this propritetary way of storing plural, see https://github.com/translate/translate/issues/4614

nijel avatar Apr 25 '24 08:04 nijel

The issue you've reported needs to be addressed in the translate-toolkit. Please file the issue there, and include links to any relevant specifications about the formats (if applicable).

github-actions[bot] avatar Apr 25 '24 09:04 github-actions[bot]

I understand that this is a proprietary way of handling plurals in XLIFF, and I don't expect Weblate to provide first-class support to them. But I'm still confused about why the "one" and "other" strings are displayed while "few" and "many" are not. Is this also part of translate? Because the bug reports there imply they should be present, just not recognized as plural forms. Thanks!

bryceco avatar Apr 25 '24 16:04 bryceco

I guess you've configured it as monolingual format and in that case only keys present in the source file are shown.

nijel avatar Apr 25 '24 17:04 nijel

All 4 plurals are present in the XLIFF I'm uploading. Or maybe I misunderstand you. Edit: Okay, I think I see what you mean. So I should be able to fix it by disabling monolingual. Edit2: Removing the "Monolingual base language file" setting seems give me the result I wanted. Thanks @nijel!

bryceco avatar Apr 25 '24 17:04 bryceco