-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fix: PluralRules for Czech locale #325
Conversation
I added new Czech PluralRuleDelegate according to Czech grammar. It would break the usage of an old rule, however I don't believe it could have been used in real word. The test should be: public void SmartFormatPluralTest() { var c = new CustomPluralRuleProvider(Czech); string msg = "{0:plural:Nemáte zprávu|Máte {} zprávu|Přišly Vám {} zprávy|Přišlo Vám {} zpráv}!"; Smart.Format(c, msg, 0).Should().Be("Nemáte zprávu!"); Smart.Format(c, msg, 1).Should().Be("Máte 1 zprávu!"); Smart.Format(c, msg, 2).Should().Be("Přišly Vám 2 zprávy!"); Smart.Format(c, msg, 4).Should().Be("Přišly Vám 4 zprávy!"); Smart.Format(c, msg, 5).Should().Be("Přišlo Vám 5 zpráv!"); Smart.Format(c, msg, 6).Should().Be("Přišlo Vám 6 zpráv!"); }
Codecov ReportBase: 96% // Head: 96% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #325 +/- ##
===================================
Coverage 96% 96%
===================================
Files 91 91
Lines 3183 3185 +2
===================================
+ Hits 3067 3069 +2
Misses 116 116
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Good catch, Alex, that seems to be consistent with this document as far as I understand without speaking Czech. Assume you're a native speaker 😉 |
Hello,
As you see I noticed that SmartFormat does not serve negative values properly (look at Math.Abs used) and I believe this could be a problem in many languages..? Note: The other comments can be discussed here: #327 |
Indeed, only positive arguments are implemented. |
Fixed version of Czech PluralRule with support of fractions.
Hello, so I made final Czech Rule, ignoring negative values. Well, handling them would be breaking change, however - there could be an optional switch i.e. The test for this should be (frankly I don't know where to put it):
|
I went through the unit tests, and there are tests using negative values. |
* Update PluralRes to fix Czech plural rules I added new Czech PluralRuleDelegate according to Czech grammar. It would break the usage of an old rule, however I don't believe it could have been used in real word. The test should be: public void SmartFormatPluralTest() { var c = new CustomPluralRuleProvider(Czech); string msg = "{0:plural:Nemáte zprávu|Máte {} zprávu|Přišly Vám {} zprávy|Přišlo Vám {} zpráv}!"; Smart.Format(c, msg, 0).Should().Be("Nemáte zprávu!"); Smart.Format(c, msg, 1).Should().Be("Máte 1 zprávu!"); Smart.Format(c, msg, 2).Should().Be("Přišly Vám 2 zprávy!"); Smart.Format(c, msg, 4).Should().Be("Přišly Vám 4 zprávy!"); Smart.Format(c, msg, 5).Should().Be("Přišlo Vám 5 zpráv!"); Smart.Format(c, msg, 6).Should().Be("Přišlo Vám 6 zpráv!"); } * Update PluralRules.cs Fixed version of Czech PluralRule with support of fractions. * Add unit tests for Czech locale Co-authored-by: axunonb <[email protected]>
I added new Czech PluralRuleDelegate according to Czech grammar. It would break the usage of an old rule, however I don't believe it could have been used in real word. The test should be: