diff --git a/internal/plural/codegen/plurals.xml b/internal/plural/codegen/plurals.xml
index 9b1100a2..26cca255 100644
--- a/internal/plural/codegen/plurals.xml
+++ b/internal/plural/codegen/plurals.xml
@@ -1,7 +1,7 @@
-
+
i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04
@integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~2.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
@@ -27,7 +27,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic
i = 0,1 @integer 0, 1 @decimal 0.0~1.5
@integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
-
+
i = 1 and v = 0 @integer 1
@integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
@@ -76,12 +76,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic
i = 0,1 and n != 0 @integer 1 @decimal 0.1~1.6
@integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
-
- n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000
- n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000
- @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
-
-
+
n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000
n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000
@integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
@@ -197,6 +192,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic
+
+ n % 10 = 1 and n % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, …
+ n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000
+ n != 2 and n % 10 = 2..9 and n % 100 != 11..19 @integer 3~9, 22~29, 32, 102, 1002, … @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 22.0, 102.0, 1002.0, …
+ f != 0 @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, …
+ @integer 0, 10~20, 30, 40, 50, 60, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
+
n % 10 = 1 and n % 100 != 11,71,91 @integer 1, 21, 31, 41, 51, 61, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 81.0, 101.0, 1001.0, …
n % 10 = 2 and n % 100 != 12,72,92 @integer 2, 22, 32, 42, 52, 62, 82, 102, 1002, … @decimal 2.0, 22.0, 32.0, 42.0, 52.0, 62.0, 82.0, 102.0, 1002.0, …
diff --git a/internal/plural/rule_gen.go b/internal/plural/rule_gen.go
index a19c8916..66e18d8f 100644
--- a/internal/plural/rule_gen.go
+++ b/internal/plural/rule_gen.go
@@ -12,7 +12,7 @@ func DefaultRules() Rules {
return Other
},
})
- addPluralRules(rules, []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "pcm", "zu"}, &Rule{
+ addPluralRules(rules, []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "kok", "kok_Latn", "pcm", "zu"}, &Rule{
PluralForms: newPluralFormSet(One, Other),
PluralFormFunc: func(ops *Operands) Form {
// i = 0 or n = 1
@@ -33,7 +33,7 @@ func DefaultRules() Rules {
return Other
},
})
- addPluralRules(rules, []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}, &Rule{
+ addPluralRules(rules, []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "ie", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}, &Rule{
PluralForms: newPluralFormSet(One, Other),
PluralFormFunc: func(ops *Operands) Form {
// i = 1 and v = 0
@@ -162,21 +162,7 @@ func DefaultRules() Rules {
return Other
},
})
- addPluralRules(rules, []string{"blo"}, &Rule{
- PluralForms: newPluralFormSet(Zero, One, Other),
- PluralFormFunc: func(ops *Operands) Form {
- // n = 0
- if ops.NEqualsAny(0) {
- return Zero
- }
- // n = 1
- if ops.NEqualsAny(1) {
- return One
- }
- return Other
- },
- })
- addPluralRules(rules, []string{"ksh"}, &Rule{
+ addPluralRules(rules, []string{"blo", "cv", "ksh"}, &Rule{
PluralForms: newPluralFormSet(Zero, One, Other),
PluralFormFunc: func(ops *Operands) Form {
// n = 0
@@ -480,6 +466,28 @@ func DefaultRules() Rules {
return Other
},
})
+ addPluralRules(rules, []string{"sgs"}, &Rule{
+ PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
+ PluralFormFunc: func(ops *Operands) Form {
+ // n % 10 = 1 and n % 100 != 11
+ if ops.NModEqualsAny(10, 1) && !ops.NModEqualsAny(100, 11) {
+ return One
+ }
+ // n = 2
+ if ops.NEqualsAny(2) {
+ return Two
+ }
+ // n != 2 and n % 10 = 2..9 and n % 100 != 11..19
+ if !ops.NEqualsAny(2) && ops.NModInRange(10, 2, 9) && !ops.NModInRange(100, 11, 19) {
+ return Few
+ }
+ // f != 0
+ if !intEqualsAny(ops.F, 0) {
+ return Many
+ }
+ return Other
+ },
+ })
addPluralRules(rules, []string{"br"}, &Rule{
PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
PluralFormFunc: func(ops *Operands) Form {
diff --git a/internal/plural/rule_gen_test.go b/internal/plural/rule_gen_test.go
index b949dfb1..9cb3f318 100644
--- a/internal/plural/rule_gen_test.go
+++ b/internal/plural/rule_gen_test.go
@@ -16,7 +16,7 @@ func TestBmBoDzHnjIdIgIiInJaJboJvJwKdeKeaKmKoLktLoMsMyNqoOsaRootSahSesSgSuThToTp
}
}
-func TestAmAsBnDoiFaGuHiKnPcmZu(t *testing.T) {
+func TestAmAsBnDoiFaGuHiKnKokKok_latnPcmZu(t *testing.T) {
var tests []pluralFormTest
tests = appendIntegerTests(tests, One, []string{"0", "1"})
@@ -25,7 +25,7 @@ func TestAmAsBnDoiFaGuHiKnPcmZu(t *testing.T) {
tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
tests = appendDecimalTests(tests, Other, []string{"1.1~2.6", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
- locales := []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "pcm", "zu"}
+ locales := []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "kok", "kok_Latn", "pcm", "zu"}
for _, locale := range locales {
runTests(t, locale, tests)
}
@@ -46,7 +46,7 @@ func TestFfHyKab(t *testing.T) {
}
}
-func TestAstDeEnEtFiFyGlIaIoJiLijNlScSvSwUrYi(t *testing.T) {
+func TestAstDeEnEtFiFyGlIaIeIoJiLijNlScSvSwUrYi(t *testing.T) {
var tests []pluralFormTest
tests = appendIntegerTests(tests, One, []string{"1"})
@@ -54,7 +54,7 @@ func TestAstDeEnEtFiFyGlIaIoJiLijNlScSvSwUrYi(t *testing.T) {
tests = appendIntegerTests(tests, Other, []string{"0", "2~16", "100", "1000", "10000", "100000", "1000000"})
tests = appendDecimalTests(tests, Other, []string{"0.0~1.5", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
- locales := []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}
+ locales := []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "ie", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}
for _, locale := range locales {
runTests(t, locale, tests)
}
@@ -216,7 +216,7 @@ func TestLag(t *testing.T) {
}
}
-func TestBlo(t *testing.T) {
+func TestBloCvKsh(t *testing.T) {
var tests []pluralFormTest
tests = appendIntegerTests(tests, Zero, []string{"0"})
@@ -228,25 +228,7 @@ func TestBlo(t *testing.T) {
tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
tests = appendDecimalTests(tests, Other, []string{"0.1~0.9", "1.1~1.7", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
- locales := []string{"blo"}
- for _, locale := range locales {
- runTests(t, locale, tests)
- }
-}
-
-func TestKsh(t *testing.T) {
- var tests []pluralFormTest
-
- tests = appendIntegerTests(tests, Zero, []string{"0"})
- tests = appendDecimalTests(tests, Zero, []string{"0.0", "0.00", "0.000", "0.0000"})
-
- tests = appendIntegerTests(tests, One, []string{"1"})
- tests = appendDecimalTests(tests, One, []string{"1.0", "1.00", "1.000", "1.0000"})
-
- tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
- tests = appendDecimalTests(tests, Other, []string{"0.1~0.9", "1.1~1.7", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
-
- locales := []string{"ksh"}
+ locales := []string{"blo", "cv", "ksh"}
for _, locale := range locales {
runTests(t, locale, tests)
}
@@ -561,6 +543,29 @@ func TestRuUk(t *testing.T) {
}
}
+func TestSgs(t *testing.T) {
+ var tests []pluralFormTest
+
+ tests = appendIntegerTests(tests, One, []string{"1", "21", "31", "41", "51", "61", "71", "81", "101", "1001"})
+ tests = appendDecimalTests(tests, One, []string{"1.0", "21.0", "31.0", "41.0", "51.0", "61.0", "71.0", "81.0", "101.0", "1001.0"})
+
+ tests = appendIntegerTests(tests, Two, []string{"2"})
+ tests = appendDecimalTests(tests, Two, []string{"2.0", "2.00", "2.000", "2.0000"})
+
+ tests = appendIntegerTests(tests, Few, []string{"3~9", "22~29", "32", "102", "1002"})
+ tests = appendDecimalTests(tests, Few, []string{"3.0", "4.0", "5.0", "6.0", "7.0", "8.0", "9.0", "22.0", "102.0", "1002.0"})
+
+ tests = appendDecimalTests(tests, Many, []string{"0.1~0.9", "1.1~1.7", "10.1", "100.1", "1000.1"})
+
+ tests = appendIntegerTests(tests, Other, []string{"0", "10~20", "30", "40", "50", "60", "100", "1000", "10000", "100000", "1000000"})
+ tests = appendDecimalTests(tests, Other, []string{"0.0", "10.0", "11.0", "12.0", "13.0", "14.0", "15.0", "16.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
+
+ locales := []string{"sgs"}
+ for _, locale := range locales {
+ runTests(t, locale, tests)
+ }
+}
+
func TestBr(t *testing.T) {
var tests []pluralFormTest