weblate
weblate copied to clipboard
Add support for Apple XLIFF
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) |==|plural.few" xml:space="preserve">
<source> (%d members)</source>
<target state="translated"> (%d элемета)</target>
<note/>
</trans-unit>
<trans-unit id=" (%d members) |==|plural.many" xml:space="preserve">
<source> (%d members)</source>
<target state="translated"> (%d элементов)</target>
<note/>
</trans-unit>
<trans-unit id=" (%d members) |==|plural.one" xml:space="preserve">
<source> (%d member)</source>
<target state="translated"> (%d элемент)</target>
<note/>
</trans-unit>
<trans-unit id=" (%d members) |==|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
- Verify that the translation file linked above contains "few"/"many" plurals.
- 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
Weblate doesn't yet support this propritetary way of storing plural, see https://github.com/translate/translate/issues/4614
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).
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!
I guess you've configured it as monolingual format and in that case only keys present in the source file are shown.
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!