Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Set the device language to Latvian.
- Tap on Floating action button to increment value.
Actual results
When the device language is set to Latvian, the plural strings are not handled correctly. For example, the string for the count "10" should be "10 punkti," but it incorrectly returns "Nav pievienotu punktu."
In English
"count": "{count, plural, =0{No points added} =1{1 point} other{{count} points}}",
In Latvian would be
"count": "{count, plural, =0{Nav pievienotu punktu} =1{1 punkts} other{{count} punkti}}",
0 returning = Nav pievienotu punktu
1 returning = 1 punkts
2 to 9 returning correct string
However when it hits 10 showing "Nav pievienotu punktu" so all the way up to 20.
21 showing = 1 punkts
22 showing = 22 -29 correct result
30 showing = Nav pievienotu punktu
31 showing = 1 punkts
33 showing = 33 punkti
And so on.
Logs
Logs
No logs
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.19045.3324], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2022 17.5.5)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.81.1)
[√] Connected device (4 available)
[√] Network resources
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)Supporting other languages or locales. (aka i18n)found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
ReinisSprogis commentedon Aug 24, 2023
I dug little bit around and seems like bug is in the
PluralCase _lv_ruleplural_rules.dart.I'm not exactly sure what is happening there, but seems like it could be it.
darshankawar commentedon Aug 25, 2023
Thanks for the report. I was able to replicate this using latest stable and master versions, whererin, from 1 to 10, it shows correctly as
punktu, but from 10 onwards, it shows as below:The text above 10 in English means
no points added.stable, master flutter doctor -v
gampixi commentedon Aug 28, 2023
Someone who's more experienced with doing Latvian l10n should probably chime in, but as a native speaker I can't imagine why the condition for
PluralCase.ZEROneeds to be so complicated.The noun changes between singular and plural - generally singular if the count ends with 1 (1 punkts, 21 punkts, 201 punkts, 22 punkti) (except in the case of 11 (11 punkti, 211 punkti)), and plural for the rest (0 punkti, 10 punkti, 20 punkti).
As far as I'm aware, we'd need the zero case only for zero - and only because it would be preferable to provide a custom string for 0.
The
PluralCase.ONEcondition (for specifying when singular noun must be used) seems correct at a glance, though.gampixi commentedon Aug 28, 2023
And @ReinisSprogis , you should use the
{count}placeholder for the=1case, as for Latvian it appears to refer to any case where the singular noun must be used. As a workaround, you can have the=0case match the plural, which would be grammatically correct ("0 punkti", "10 punkti" and so on).volo commentedon Dec 5, 2023
That's unfortunately how plural category names for the Latvian language are defined in the Unicode Common Locale Data Repository (CLDR).
As stated by a Latvian native speaker in a different issue php-gettext/Languages#45 (comment) :
The Latvian plural form rules are defined by CLDR here, and the Lithuanian are here.
So there's a discrepancy, and while Latvian follows the plural category names recommendations defined by the CLDR:
but it makes Latvian the only modernly spoken language that uses
zeroplural category for cardinals other then0.And that would be just okay, but then in 2010s Apple entered the stage with a "brilliant" (not!) idea of using the
zerocategory for cases with a zero quantity values to facilitate negative forms of sentences (i.e.: "You have no emails" instead of "You have 0 emails"). So, instead of introducing a custom quantity category likenoneor=0they messed up the CLDR categories and plural rules, completely disregarding the fact that it won't work properly for the Latvian language. (More detailed info about the Apple's implementation can be found here: https://stackoverflow.com/a/61426762). Android didn't follow that slippery slope, but now and then I see Android devs complaining online thatzeroplural category doesn't work as it's supposed to work 🤷🏻♂️The solution is to not use the plural strings for something they were never intended for (I'm looking at you Apple), but instead handle negative/absence form in the code (Kotlin+Android example below, but the code is straightforward):
Or handle it with ICU MessageFormat:
@ReinisSprogis to sum it up, for Latvian you should add both
zeroplural category and=0pattern if you'd like to explicitly handle the case for the absence of points:And I guess, you also need the
oneplural category to handle proper plural forms of quantities like 21, 31, …FWIW, native Android implementation with the absence of
zeropart in the message patterns above fallbacks toother. If that's not the case for Flutter then there's indeed a bug in the ICU message format implementation.[gen_l10n] Add `use-explicit-plural-values` option (flutter#194816)