WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.54k stars 1k forks source link

Add support for Apple XLIFF #11483

Open bryceco opened 5 months ago

bryceco commented 5 months ago

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

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

nijel commented 5 months ago

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

github-actions[bot] commented 5 months ago

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

bryceco commented 5 months ago

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!

nijel commented 5 months ago

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

bryceco commented 5 months ago

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!