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

Fall back to English plural rules instead of crashing on unknown locale #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacobras
Copy link

@jacobras jacobras commented Jan 9, 2024

Currently the library crashes on JS when using any language that doesn't have a set of PluralRules. See #53.

They should be added when needed, but I suggest not crashing on it. It's better to fall back to the English formatting rule. For many languages this will already be correct and the ones that need something else should get a custom configuration.

I would like to add some logging still when the fallback is triggered, but there's no logging mechanism in Libres currently so that's omitted.

For many languages this will already be correct and for the ones that needs a custom configuration, at least it won't crash anymore.
@@ -73,7 +73,7 @@ object PluralRules {
"uk" -> Ukrainian
"kk" -> Kazakh
"fr" -> French
else -> custom[languageCode] ?: error("Plural rule for '$languageCode' not provided")
else -> custom[languageCode] ?: English
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to add some logging here, but there's no logging mechanism in the library currently.

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 this pull request may close these issues.

1 participant