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

Plural Support Missing 'Few' Case for Some Languages Like Arabic | Default Behavior of ignorePluralRules #729

Closed
MAlazhariy opened this issue Nov 25, 2024 · 1 comment · Fixed by #730

Comments

@MAlazhariy
Copy link
Contributor

MAlazhariy commented Nov 25, 2024

I’ve encountered an issue with the plural functionality in easy_localization, which no longer supports the 'few' case for certain languages, including Arabic. This is critical because Arabic uses the 'few' case for numbers less than or equal to 10, while numbers from 11 and above use a different form (usually considered 'other').

After tracing the issue in the library, I found that the variable ignorePluralRules is set to a default value of true, which causes the library to ignore the pluralization rules for the language being used.

As a result, it defaults to the _pluralCaseFallback function, which only handles the following cases: ZERO, ONE, TWO, OTHER.

This means the pluralization rules won’t be applied unless the ignorePluralRules variable is explicitly set to false during package initialization. You can do this as follows:

runApp(
  EasyLocalization(
    supportedLocales: [Locale('en'), Locale('ar')],
    path: 'assets/translations',
    fallbackLocale: Locale('en'),
    ignorePluralRules: false, // Should be set to FALSE to apply the language’s plural rules
    child: const MyApp(),
  );
);

Unfortunately, this is not mentioned in the project’s README, and it has never been pointed out in the documentation.

I believe it makes more sense for the default value of ignorePluralRules to be set to false so that the language’s plural rules are not ignored by default. If users want to change this behavior, they can manually set it to true.


Required:

  • Set the default value of ignorePluralRules to false instead of true.
  • (Recommended) Add a note about this change in the README file.

Thanks!

@MAlazhariy MAlazhariy changed the title Plural Support Missing 'Few' Case for some languages like Arabic Plural Support Missing 'Few' Case for Some Languages Like Arabic | Default Behavior of ignorePluralRules Nov 25, 2024
@MAlazhariy
Copy link
Contributor Author

I’ve realized that most popular languages, such as English, don’t require the few and many plural cases, as they may rely on one and other.

Therefore, I kept the existing implementation unchanged in my PR #730.

In addition, I’ve added unit tests covering pluralization scenarios for three languages, including Arabic, to ensure proper behavior. I’ve also updated the README documentation to highlight the details regarding plural rules configuration.

Looking forward to your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant