Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android lint errors when cs/fr/lt/sk are missing "many" in plurals, Weblate does not #7520

Open
2 tasks done
eighthave opened this issue Apr 20, 2022 · 17 comments
Open
2 tasks done
Labels
enhancement Adding or requesting a new feature. undecided These features might not be implemented. Can be prioritized by sponsorship.

Comments

@eighthave
Copy link
Contributor

Describe the issue

Android's lint tool is complaining about missing "many" entries in plural strings for "cs" (Czech), "fr" (French) , "lt" (Lithuanian), and "sk" (Slovak). The Weblate interface does not offer "many" as an option for those languages/strings. For example:

https://gitlab.com/grote/fdroidclient/-/jobs/2351872888

    ^
/builds/grote/fdroidclient/app/src/main/res/values-cs/strings.xml:396: Error: For locale "cs" (Czech) the following quantities should also be defined: many [MissingQuantity]
    <plurals name="details_last_update_months">
    ^
/builds/grote/fdroidclient/app/src/main/res/values-cs/strings.xml:401: Error: For locale "cs" (Czech) the following quantities should also be defined: many [MissingQuantity]
    <plurals name="details_last_update_years">
    ^
/builds/grote/fdroidclient/app/src/main/res/values-lt/strings.xml:406: Error: For locale "lt" (Lithuanian) the following quantities should also be defined: many [MissingQuantity]
    <plurals name="button_view_all_apps_in_category">
    ^
/builds/grote/fdroidclient/app/src/main/res/values-lt/strings.xml:501: Error: For locale "lt" (Lithuanian) the following quantities should also be defined: many [MissingQuantity]
    <plurals name="tts_view_all_in_category">
    ^
   Explanation for issues of type "MissingQuantity":
   Different languages have different rules for grammatical agreement with
   quantity. In English, for example, the quantity 1 is a special case. We
   write "1 book", but for any other quantity we'd write "n books". This
   distinction between singular and plural is very common, but other languages
   make finer distinctions.
   This lint check looks at each translation of a <plural> and makes sure that
   all the quantity strings considered by the given language are provided by
   this translation.
   For example, an English translation must provide a string for
   quantity="one". Similarly, a Czech translation must provide a string for
   quantity="few".
   https://developer.android.com/guide/topics/resources/string-resource.html#Plurals

This is related to #1550. This site seems to say it is a matter of conversion between the CLDR and gettext representation schemes for plurals:
https://github.com/miracle2k/android2po#plurals-support

I already tried

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

Steps to reproduce the behavior

These are some of the strings:

Expected behavior

Weblate should support the "many" field for Android strings.xml for cs/fr/lt/sk languages.

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
Copy link
Member

nijel commented Apr 21, 2022

This definitely was not the case in the past, what has changed in Android regarding this? Weblate uses CLDR data for Android.

The many plural is used for decimal numbers (see https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html#cs) and that indeed cannot be represented in Weblate right now.

@eighthave
Copy link
Contributor Author

I'm not sure exactly when it changed, it could have been a while ago since I haven't been too active working on Android things recently.

Here's the lint check code:
https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/PluralsDetector.kt?q=%22the%20following%20quantities%20should%20also%20be%20defined%22

@nijel
Copy link
Member

nijel commented Apr 21, 2022

It was introduced in https://cs.android.com/android-studio/platform/tools/base/+/97f96e70464579c01712dec78bb398d2e47582df, unfortunately the commit does not include any reasoning...

@nijel
Copy link
Member

nijel commented Apr 26, 2022

Weblate certainly could be changed to deal with non-integer plurals. On the other side, most of the applications don't really need this, and it would add one additional string to translate (and confuse translators because they are currently not used to this).

@nijel nijel added enhancement Adding or requesting a new feature. undecided These features might not be implemented. Can be prioritized by sponsorship. labels Apr 26, 2022
@eighthave
Copy link
Contributor Author

eighthave commented Apr 26, 2022 via email

@github-actions
Copy link

This issue has been put aside. It is currently unclear if it will ever be implemented as it seems to cover too narrow of a use case or doesn't seem to fit into Weblate.

Please try to clarify the use case or consider proposing something more generic to make it useful to more users.

@eighthave
Copy link
Contributor Author

eighthave commented Apr 26, 2022 via email

@warting
Copy link

warting commented Apr 29, 2022

maybe make it configurable in weblate what kind of different plurals it exists for each language?

@nijel
Copy link
Member

nijel commented Apr 29, 2022

The plural rules are currently detected based on the file. Some formats do explicitly include it (Gettext), for others we do guess what should be used (what turns out to be tricky, see for example translate/translate#786).

Having that user configurable would be possible, but I'm uncertain if it will address the issue - the choice here is between Android lint complains and translators having extra work which is not needed in most cases. Anyway, it's safe to assume that most people will not change the configuration :-).

@eighthave
Copy link
Contributor Author

eighthave commented Apr 29, 2022 via email

@nijel
Copy link
Member

nijel commented Apr 29, 2022

Apparently, it was intentional change there. Knowing the reasons might help us understand that as well...

@eighthave
Copy link
Contributor Author

Based on the info here, my guess is that they added support for many to support strings with decimal numbers in them. Seems like just an incremental improvement to their localization support. Their test example is in Czech, does it make sense?

                                        + "<plurals name=\"product_type_ch_adult_general_abonnement\">\n"
                                        + "  <item quantity=\"few\">%d dospělí (karta GA)</item>\n"
                                        + "  <item quantity=\"many\">%d dospělých (karta GA)</item>\n"
                                        + "  <item quantity=\"one\">%d Dospělý (GA travelcard)</item>\n"
                                        + "  <item quantity=\"other\">%d Dospělí/dospělých (GA travelcard)</item>\n"
                                        + "</plurals>"))

@nijel
Copy link
Member

nijel commented May 3, 2022

Yes, it makes grammatical sense when you need decimals. The problem is that you don't need them in numerous instances. In this case, you won't have two and half adults, as you usually don't cut them ;-).

Anyway, to support this in Weblate:

  • the plural rules have to be expanded to handle decimals
  • translate-toolkit needs to understand these as well
  • translate-toolkit should be able to migrate from the old to new plurals (it currently stores them in the list, so other would become many and other would be untranslated
  • additional plural rules need to be added for Android in Weblate
  • migrate existing translations in the Weblate database (again, these are stored sequentially, so without migration the plurals would be offset)

@eighthave eighthave changed the title Android lint errors when ca/fr/lt/sk are missing "many" in plurals, Weblate does not Android lint errors when cs/fr/lt/sk are missing "many" in plurals, Weblate does not May 18, 2022
@kzaikin
Copy link

kzaikin commented Jul 13, 2022

@samofcorinth could you explain the reasoning behind change from other to many (the discussion above)?
For example, Android pluralization engine and translation services (weblate.org or crowdin.com) use one|other for French, while android linter requires it to have 'one|many' - that requires us to treat lint issues as false-positives.

@samofcorinth
Copy link

Android Lint gets its plural data from this page: https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_plural_rules.html#fr
According to this page, French (and the other languages) indeed has the many plural form. The version of the table that added many was v38 (introduced in 2020), so most likely Weblate's data came from a version before this one.

nijel added a commit to WeblateOrg/language-data that referenced this issue Jul 14, 2022
These added exponent based conditions to several languages.

See WeblateOrg/weblate#7520
nijel added a commit that referenced this issue Jul 14, 2022
We will need these to properly handle changes in Android / CLDR.

See #7520
@nijel
Copy link
Member

nijel commented Jul 14, 2022

French seems a bit different here - there is an additional n % 1000000 condition for many which was indeed introduced in CLDR v38, see unicode-org/cldr@4116d54 and https://unicode-org.atlassian.net/browse/CLDR-12010.

For cs/lt/sk the issue is described above - it affects decimal numbers only.

@nijel
Copy link
Member

nijel commented Jul 14, 2022

I've split out #7888 to handle CLDR 38+ plural changes.

TheLastProject added a commit to CatimaLoyalty/Android that referenced this issue Apr 4, 2023
lneugebauer added a commit to lneugebauer/nextcloud-cookbook that referenced this issue Oct 12, 2023
PaulWoitaschek added a commit to PaulWoitaschek/Voice that referenced this issue Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature. undecided These features might not be implemented. Can be prioritized by sponsorship.
Projects
None yet
Development

No branches or pull requests

5 participants