[FEAT] Add CLDR plural form support to localization system#707
Merged
sadespresso merged 1 commit intoflow-mn:developfrom Apr 21, 2026
Merged
[FEAT] Add CLDR plural form support to localization system#707sadespresso merged 1 commit intoflow-mn:developfrom
sadespresso merged 1 commit intoflow-mn:developfrom
Conversation
- Track current locale via _currentLocale static field - Add _pluralCategory() implementing CLDR plural rules for 14 languages - When getTransalation() receives a num value, resolve CLDR category and look for suffixed key (key.one, key.few, key.many) before fallback - Add plural form keys for transaction counts in 11 language files - Update l10n integrity test to handle plural suffix keys
bf6df90 to
2aa671d
Compare
sadespresso
approved these changes
Apr 21, 2026
Collaborator
sadespresso
left a comment
There was a problem hiding this comment.
lgtm! thank you! the backwards compat is huge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add CLDR plural form support to the localization system, enabling correct plural forms for all 14 supported languages.
Closes #706
Problem
The current localization system uses a single translation string for numeric values, which results in grammatically incorrect output in languages with complex plural rules. For example, in Polish: "1 transakcji" (incorrect) instead of "1 transakcja" (correct).
Solution
Core changes (
lib/l10n/flow_localizations.dart)_currentLocalestatic field_pluralCategory(num n, String langCode)method implementing CLDR plural rules for all supported languages:getTransalation()receives anumvalue, it resolves the CLDR plural category and looks for a suffixed key (e.g.,key.one,key.few,key.many) before falling back to the base keyTranslation keys
Added plural form keys for transaction counts in 11 language files:
tabs.home.transactionsCount.{category}transactions.count.{category}Languages with plural keys: en, pl, ru, uk, be, cs, ar, it, fr, es, de.
Languages skipped (nouns don't inflect after numbers): tr, mn, fa.
How it works
Translation authors add suffixed keys alongside the base key:
{ "transactions.count": "{} transakcji", "transactions.count.one": "{} transakcja", "transactions.count.few": "{} transakcje", "transactions.count.many": "{} transakcji" }The system automatically selects the correct form based on the numeric value and current locale. If no plural key exists, it falls back to the base key — fully backward compatible.
Testing