weblate icon indicating copy to clipboard operation
weblate copied to clipboard

Plurals with empty variants are kept in Android

Open lucasmz-dev opened this issue 7 months ago • 6 comments

Describe the issue

If a contributor is to leave a plural empty, like only translating singular, that plural is added as an empty string into the translation file. This doesn't seem to be noticed by Android lint or anything, what this seems to result is literally just empty strings in-app, as well as not really warning the developer, other than the failing check.

https://github.com/mjaakko/NeoStumbler/blob/f6b56db840f53104b106f2d943694d555cc2b07a/app/src/main/res/values-fr-rFR/strings.xml#L191

https://hosted.weblate.org/translate/neostumbler/neostumbler/fr/?checksum=ea08702b574771e3

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. Translate an Android plural but keep one variant empty (e.g. many in pt)

Expected behavior

Since "Remove blank strings" is enabled, I would kind of expect that to also remove these. I can see how internally it's not really built for that though.

Screenshots

No response

Exception traceback


How do you run Weblate?

weblate.org service

Weblate versions

No response

Weblate deploy checks


Additional context

No response

lucasmz-dev avatar May 19 '25 10:05 lucasmz-dev

The remove blank strings operates on strings, not on plural forms, so this is expected.

The completely missing plural would AFAIK trigger in the Android lint, but would that somehow reasonable work in Android itself? What happens if the file contains only:

    <plurals name="wifi_filter_settings_description">
        <item quantity="many">%d SSID filtrés</item>
    </plurals>

nijel avatar May 19 '25 11:05 nijel

(linting disabled)

Test 1:

only one and many: crashes when anything over 1 needs to be displayed

Test 2:

only one and other: seems to work fine, not sure if a string with > 1.000.000 would cause a crash but I think Android doesn't even complain about the lack of many usually I guess translators are used to not translating for that + some translation platforms not supporting it

... doing next tests

lucasmz-dev avatar May 19 '25 12:05 lucasmz-dev

Test 3:

only many: basically the same as test 1, but now it crashed just opening that screen since the default is 0

lucasmz-dev avatar May 19 '25 12:05 lucasmz-dev

Android does seem to have some handling for some extra cases, right now nb-rNO only has other and that works fine, if French was like that I believe it would be the same

lucasmz-dev avatar May 19 '25 12:05 lucasmz-dev

I guess the end result is that when it works it is an exception rather than the rule, so it's either a silent error to the developer, which causes strings to be emptied out, as if they were just nothing instead of falling back to the source language (there is always the failing check in Weblate to be fair) (current behavior) or a very explicit error to the developer (suggested behavior)

lucasmz-dev avatar May 19 '25 12:05 lucasmz-dev

What you can do is to configure missing plural as an enforced check in Weblate, that will mark these strings as needing editing making it more obvious to translators that this has to be fixed.

nijel avatar May 22 '25 10:05 nijel