Skip to content

Commit fd35d7b

Browse files
authored
Update to CLDR v48 (#398)
1 parent 54fa2a2 commit fd35d7b

File tree

3 files changed

+65
-50
lines changed

3 files changed

+65
-50
lines changed

internal/plural/codegen/plurals.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<!DOCTYPE supplementalData SYSTEM "../../common/dtd/ldmlSupplemental.dtd">
33
<!--
4-
Copyright © 1991-2024 Unicode, Inc.
4+
Copyright © 1991-2025 Unicode, Inc.
55
For terms of use, see http://www.unicode.org/copyright.html
66
SPDX-License-Identifier: Unicode-3.0
77
CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
@@ -19,15 +19,15 @@ CLDR data files are interpreted according to the LDML specification (http://unic
1919

2020
<!-- 2: one,other -->
2121

22-
<pluralRules locales="am as bn doi fa gu hi kn pcm zu">
22+
<pluralRules locales="am as bn doi fa gu hi kn kok kok_Latn pcm zu">
2323
<pluralRule count="one">i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04</pluralRule>
2424
<pluralRule count="other"> @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, …</pluralRule>
2525
</pluralRules>
2626
<pluralRules locales="ff hy kab">
2727
<pluralRule count="one">i = 0,1 @integer 0, 1 @decimal 0.0~1.5</pluralRule>
2828
<pluralRule count="other"> @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, …</pluralRule>
2929
</pluralRules>
30-
<pluralRules locales="ast de en et fi fy gl ia io ji lij nl sc sv sw ur yi">
30+
<pluralRules locales="ast de en et fi fy gl ia ie io ji lij nl sc sv sw ur yi">
3131
<pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
3232
<pluralRule count="other"> @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, …</pluralRule>
3333
</pluralRules>
@@ -76,12 +76,7 @@ CLDR data files are interpreted according to the LDML specification (http://unic
7676
<pluralRule count="one">i = 0,1 and n != 0 @integer 1 @decimal 0.1~1.6</pluralRule>
7777
<pluralRule count="other"> @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, …</pluralRule>
7878
</pluralRules>
79-
<pluralRules locales="blo">
80-
<pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
81-
<pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
82-
<pluralRule count="other"> @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, …</pluralRule>
83-
</pluralRules>
84-
<pluralRules locales="ksh">
79+
<pluralRules locales="blo cv ksh">
8580
<pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
8681
<pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
8782
<pluralRule count="other"> @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, …</pluralRule>
@@ -197,6 +192,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic
197192

198193
<!-- 5: one,two,few,many,other -->
199194

195+
<pluralRules locales="sgs">
196+
<pluralRule count="one">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, …</pluralRule>
197+
<pluralRule count="two">n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule>
198+
<pluralRule count="few">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, …</pluralRule>
199+
<pluralRule count="many">f != 0 @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, …</pluralRule>
200+
<pluralRule count="other"> @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, …</pluralRule>
201+
</pluralRules>
200202
<pluralRules locales="br">
201203
<pluralRule count="one">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, …</pluralRule>
202204
<pluralRule count="two">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, …</pluralRule>

internal/plural/rule_gen.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func DefaultRules() Rules {
1212
return Other
1313
},
1414
})
15-
addPluralRules(rules, []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "pcm", "zu"}, &Rule{
15+
addPluralRules(rules, []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "kok", "kok_Latn", "pcm", "zu"}, &Rule{
1616
PluralForms: newPluralFormSet(One, Other),
1717
PluralFormFunc: func(ops *Operands) Form {
1818
// i = 0 or n = 1
@@ -33,7 +33,7 @@ func DefaultRules() Rules {
3333
return Other
3434
},
3535
})
36-
addPluralRules(rules, []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}, &Rule{
36+
addPluralRules(rules, []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "ie", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}, &Rule{
3737
PluralForms: newPluralFormSet(One, Other),
3838
PluralFormFunc: func(ops *Operands) Form {
3939
// i = 1 and v = 0
@@ -162,21 +162,7 @@ func DefaultRules() Rules {
162162
return Other
163163
},
164164
})
165-
addPluralRules(rules, []string{"blo"}, &Rule{
166-
PluralForms: newPluralFormSet(Zero, One, Other),
167-
PluralFormFunc: func(ops *Operands) Form {
168-
// n = 0
169-
if ops.NEqualsAny(0) {
170-
return Zero
171-
}
172-
// n = 1
173-
if ops.NEqualsAny(1) {
174-
return One
175-
}
176-
return Other
177-
},
178-
})
179-
addPluralRules(rules, []string{"ksh"}, &Rule{
165+
addPluralRules(rules, []string{"blo", "cv", "ksh"}, &Rule{
180166
PluralForms: newPluralFormSet(Zero, One, Other),
181167
PluralFormFunc: func(ops *Operands) Form {
182168
// n = 0
@@ -480,6 +466,28 @@ func DefaultRules() Rules {
480466
return Other
481467
},
482468
})
469+
addPluralRules(rules, []string{"sgs"}, &Rule{
470+
PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
471+
PluralFormFunc: func(ops *Operands) Form {
472+
// n % 10 = 1 and n % 100 != 11
473+
if ops.NModEqualsAny(10, 1) && !ops.NModEqualsAny(100, 11) {
474+
return One
475+
}
476+
// n = 2
477+
if ops.NEqualsAny(2) {
478+
return Two
479+
}
480+
// n != 2 and n % 10 = 2..9 and n % 100 != 11..19
481+
if !ops.NEqualsAny(2) && ops.NModInRange(10, 2, 9) && !ops.NModInRange(100, 11, 19) {
482+
return Few
483+
}
484+
// f != 0
485+
if !intEqualsAny(ops.F, 0) {
486+
return Many
487+
}
488+
return Other
489+
},
490+
})
483491
addPluralRules(rules, []string{"br"}, &Rule{
484492
PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
485493
PluralFormFunc: func(ops *Operands) Form {

internal/plural/rule_gen_test.go

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestBmBoDzHnjIdIgIiInJaJboJvJwKdeKeaKmKoLktLoMsMyNqoOsaRootSahSesSgSuThToTp
1616
}
1717
}
1818

19-
func TestAmAsBnDoiFaGuHiKnPcmZu(t *testing.T) {
19+
func TestAmAsBnDoiFaGuHiKnKokKok_latnPcmZu(t *testing.T) {
2020
var tests []pluralFormTest
2121

2222
tests = appendIntegerTests(tests, One, []string{"0", "1"})
@@ -25,7 +25,7 @@ func TestAmAsBnDoiFaGuHiKnPcmZu(t *testing.T) {
2525
tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
2626
tests = appendDecimalTests(tests, Other, []string{"1.1~2.6", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
2727

28-
locales := []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "pcm", "zu"}
28+
locales := []string{"am", "as", "bn", "doi", "fa", "gu", "hi", "kn", "kok", "kok_Latn", "pcm", "zu"}
2929
for _, locale := range locales {
3030
runTests(t, locale, tests)
3131
}
@@ -46,15 +46,15 @@ func TestFfHyKab(t *testing.T) {
4646
}
4747
}
4848

49-
func TestAstDeEnEtFiFyGlIaIoJiLijNlScSvSwUrYi(t *testing.T) {
49+
func TestAstDeEnEtFiFyGlIaIeIoJiLijNlScSvSwUrYi(t *testing.T) {
5050
var tests []pluralFormTest
5151

5252
tests = appendIntegerTests(tests, One, []string{"1"})
5353

5454
tests = appendIntegerTests(tests, Other, []string{"0", "2~16", "100", "1000", "10000", "100000", "1000000"})
5555
tests = appendDecimalTests(tests, Other, []string{"0.0~1.5", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})
5656

57-
locales := []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}
57+
locales := []string{"ast", "de", "en", "et", "fi", "fy", "gl", "ia", "ie", "io", "ji", "lij", "nl", "sc", "sv", "sw", "ur", "yi"}
5858
for _, locale := range locales {
5959
runTests(t, locale, tests)
6060
}
@@ -216,7 +216,7 @@ func TestLag(t *testing.T) {
216216
}
217217
}
218218

219-
func TestBlo(t *testing.T) {
219+
func TestBloCvKsh(t *testing.T) {
220220
var tests []pluralFormTest
221221

222222
tests = appendIntegerTests(tests, Zero, []string{"0"})
@@ -228,25 +228,7 @@ func TestBlo(t *testing.T) {
228228
tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
229229
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"})
230230

231-
locales := []string{"blo"}
232-
for _, locale := range locales {
233-
runTests(t, locale, tests)
234-
}
235-
}
236-
237-
func TestKsh(t *testing.T) {
238-
var tests []pluralFormTest
239-
240-
tests = appendIntegerTests(tests, Zero, []string{"0"})
241-
tests = appendDecimalTests(tests, Zero, []string{"0.0", "0.00", "0.000", "0.0000"})
242-
243-
tests = appendIntegerTests(tests, One, []string{"1"})
244-
tests = appendDecimalTests(tests, One, []string{"1.0", "1.00", "1.000", "1.0000"})
245-
246-
tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
247-
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"})
248-
249-
locales := []string{"ksh"}
231+
locales := []string{"blo", "cv", "ksh"}
250232
for _, locale := range locales {
251233
runTests(t, locale, tests)
252234
}
@@ -561,6 +543,29 @@ func TestRuUk(t *testing.T) {
561543
}
562544
}
563545

546+
func TestSgs(t *testing.T) {
547+
var tests []pluralFormTest
548+
549+
tests = appendIntegerTests(tests, One, []string{"1", "21", "31", "41", "51", "61", "71", "81", "101", "1001"})
550+
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"})
551+
552+
tests = appendIntegerTests(tests, Two, []string{"2"})
553+
tests = appendDecimalTests(tests, Two, []string{"2.0", "2.00", "2.000", "2.0000"})
554+
555+
tests = appendIntegerTests(tests, Few, []string{"3~9", "22~29", "32", "102", "1002"})
556+
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"})
557+
558+
tests = appendDecimalTests(tests, Many, []string{"0.1~0.9", "1.1~1.7", "10.1", "100.1", "1000.1"})
559+
560+
tests = appendIntegerTests(tests, Other, []string{"0", "10~20", "30", "40", "50", "60", "100", "1000", "10000", "100000", "1000000"})
561+
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"})
562+
563+
locales := []string{"sgs"}
564+
for _, locale := range locales {
565+
runTests(t, locale, tests)
566+
}
567+
}
568+
564569
func TestBr(t *testing.T) {
565570
var tests []pluralFormTest
566571

0 commit comments

Comments
 (0)