Skip to content

Commit

Permalink
Update to CLDR 31.0.1 (nicksnyder#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksnyder committed Sep 17, 2017
1 parent d0056c4 commit ca33e78
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 92 deletions.
4 changes: 2 additions & 2 deletions i18n/language/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ var codeTemplate = template.Must(template.New("spec").Parse(`package language
func init() {
{{range .PluralGroups}}
registerPluralSpec({{printf "%#v" .SplitLocales}}, &PluralSpec{
RegisterPluralSpec({{printf "%#v" .SplitLocales}}, &PluralSpec{
Plurals: newPluralSet({{range $i, $e := .PluralRules}}{{if $i}}, {{end}}{{$e.CountTitle}}{{end}}),
PluralFunc: func(ops *operands) Plural { {{range .PluralRules}}{{if .GoCondition}}
PluralFunc: func(ops *Operands) Plural { {{range .PluralRules}}{{if .GoCondition}}
// {{.Condition}}
if {{.GoCondition}} {
return {{.CountTitle}}
Expand Down
18 changes: 7 additions & 11 deletions i18n/language/codegen/plurals.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ CLDR data files are interpreted according to the LDML specification (http://unic
For terms of use, see http://www.unicode.org/copyright.html
-->
<supplementalData>
<version number="$Revision: 12002 $"/>
<version number="$Revision: 13253 $"/>
<plurals type="cardinal">
<!-- For a canonicalized list, use GeneratedPluralSamples -->

<!-- 1: other -->

<pluralRules locales="bm bo dz id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo root sah ses sg th to vi wo yo zh">
<pluralRules locales="bm bo dz id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo root sah ses sg th to vi wo yo yue zh">
<pluralRule count="other"> @integer 0~15, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
</pluralRules>

Expand All @@ -26,6 +26,10 @@ For terms of use, see http://www.unicode.org/copyright.html
<pluralRule count="one">i = 0,1 @integer 0, 1 @decimal 0.0~1.5</pluralRule>
<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>
</pluralRules>
<pluralRules locales="pt">
<pluralRule count="one">i = 0..1 @integer 0, 1 @decimal 0.0~1.5</pluralRule>
<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>
</pluralRules>
<pluralRules locales="ast ca de en et fi fy gl it ji nl sv sw ur yi">
<pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
<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>
Expand All @@ -42,18 +46,10 @@ For terms of use, see http://www.unicode.org/copyright.html
<pluralRule count="one">n = 0..1 or n = 11..99 @integer 0, 1, 11~24 @decimal 0.0, 1.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0</pluralRule>
<pluralRule count="other"> @integer 2~10, 100~106, 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>
</pluralRules>
<pluralRules locales="pt">
<pluralRule count="one">n = 0..2 and n != 2 @integer 0, 1 @decimal 0.0, 1.0, 0.00, 1.00, 0.000, 1.000, 0.0000, 1.0000</pluralRule>
<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>
</pluralRules>
<pluralRules locales="af asa az bem bez bg brx ce cgg chr ckb dv ee el eo es eu fo fur gsw ha haw hu jgo jmc ka kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn nah nb nd ne nn nnh no nr ny nyn om or os pap ps rm rof rwk saq sdh seh sn so sq ss ssy st syr ta te teo tig tk tn tr ts ug uz ve vo vun wae xh xog">
<pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
<pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
</pluralRules>
<pluralRules locales="pt_PT">
<pluralRule count="one">n = 1 and v = 0 @integer 1</pluralRule>
<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>
</pluralRules>
<pluralRules locales="da">
<pluralRule count="one">n = 1 or t != 0 and i = 0,1 @integer 1 @decimal 0.1~1.6</pluralRule>
<pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 2.0~3.4, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
Expand Down Expand Up @@ -210,7 +206,7 @@ For terms of use, see http://www.unicode.org/copyright.html

<!-- 6: zero,one,two,few,many,other -->

<pluralRules locales="ar">
<pluralRules locales="ar ars">
<pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
<pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
<pluralRule count="two">n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule>
Expand Down
4 changes: 2 additions & 2 deletions i18n/language/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func TestParse(t *testing.T) {
{"zh-TW", []*Language{{"zh-tw", pluralSpecs["zh"]}}},
{"pt-BR", []*Language{{"pt-br", pluralSpecs["pt"]}}},
{"pt_BR", []*Language{{"pt-br", pluralSpecs["pt"]}}},
{"pt-PT", []*Language{{"pt-pt", pluralSpecs["pt-pt"]}}},
{"pt_PT", []*Language{{"pt-pt", pluralSpecs["pt-pt"]}}},
{"pt-PT", []*Language{{"pt-pt", pluralSpecs["pt"]}}},
{"pt_PT", []*Language{{"pt-pt", pluralSpecs["pt"]}}},
{"zh-Hans-CN", []*Language{{"zh-hans-cn", pluralSpecs["zh"]}}},
{"zh-Hant-TW", []*Language{{"zh-hant-tw", pluralSpecs["zh"]}}},
{"en-US-en-US", []*Language{{"en-us-en-us", pluralSpecs["en"]}}},
Expand Down
34 changes: 12 additions & 22 deletions i18n/language/pluralspec_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package language

func init() {

RegisterPluralSpec([]string{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "zh"}, &PluralSpec{
RegisterPluralSpec([]string{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "yue", "zh"}, &PluralSpec{
Plurals: newPluralSet(Other),
PluralFunc: func(ops *Operands) Plural {
return Other
Expand All @@ -31,6 +31,16 @@ func init() {
return Other
},
})
RegisterPluralSpec([]string{"pt"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
PluralFunc: func(ops *Operands) Plural {
// i = 0..1
if intInRange(ops.I, 0, 1) {
return One
}
return Other
},
})
RegisterPluralSpec([]string{"ast", "ca", "de", "en", "et", "fi", "fy", "gl", "it", "ji", "nl", "sv", "sw", "ur", "yi"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
PluralFunc: func(ops *Operands) Plural {
Expand Down Expand Up @@ -73,16 +83,6 @@ func init() {
return Other
},
})
RegisterPluralSpec([]string{"pt"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
PluralFunc: func(ops *Operands) Plural {
// n = 0..2 and n != 2
if ops.NinRange(0, 2) && !ops.NequalsAny(2) {
return One
}
return Other
},
})
RegisterPluralSpec([]string{"af", "asa", "az", "bem", "bez", "bg", "brx", "ce", "cgg", "chr", "ckb", "dv", "ee", "el", "eo", "es", "eu", "fo", "fur", "gsw", "ha", "haw", "hu", "jgo", "jmc", "ka", "kaj", "kcg", "kk", "kkj", "kl", "ks", "ksb", "ku", "ky", "lb", "lg", "mas", "mgo", "ml", "mn", "nah", "nb", "nd", "ne", "nn", "nnh", "no", "nr", "ny", "nyn", "om", "or", "os", "pap", "ps", "rm", "rof", "rwk", "saq", "sdh", "seh", "sn", "so", "sq", "ss", "ssy", "st", "syr", "ta", "te", "teo", "tig", "tk", "tn", "tr", "ts", "ug", "uz", "ve", "vo", "vun", "wae", "xh", "xog"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
PluralFunc: func(ops *Operands) Plural {
Expand All @@ -93,16 +93,6 @@ func init() {
return Other
},
})
RegisterPluralSpec([]string{"pt_PT"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
PluralFunc: func(ops *Operands) Plural {
// n = 1 and v = 0
if ops.NequalsAny(1) && intEqualsAny(ops.V, 0) {
return One
}
return Other
},
})
RegisterPluralSpec([]string{"da"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
PluralFunc: func(ops *Operands) Plural {
Expand Down Expand Up @@ -512,7 +502,7 @@ func init() {
return Other
},
})
RegisterPluralSpec([]string{"ar"}, &PluralSpec{
RegisterPluralSpec([]string{"ar", "ars"}, &PluralSpec{
Plurals: newPluralSet(Zero, One, Two, Few, Many, Other),
PluralFunc: func(ops *Operands) Plural {
// n = 0
Expand Down
52 changes: 19 additions & 33 deletions i18n/language/pluralspec_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package language

import "testing"

func TestBmBoDzIdIgIiInJaJboJvJwKdeKeaKmKoLktLoMsMyNqoRootSahSesSgThToViWoYoZh(t *testing.T) {
func TestBmBoDzIdIgIiInJaJboJvJwKdeKeaKmKoLktLoMsMyNqoRootSahSesSgThToViWoYoYueZh(t *testing.T) {
var tests []pluralTest

tests = appendIntegerTests(tests, Other, []string{"0~15", "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{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "zh"}
locales := []string{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "yue", "zh"}
for _, locale := range locales {
runTests(t, locale, tests)
}
Expand Down Expand Up @@ -46,6 +46,21 @@ func TestFfFrHyKab(t *testing.T) {
}
}

func TestPt(t *testing.T) {
var tests []pluralTest

tests = appendIntegerTests(tests, One, []string{"0", "1"})
tests = appendDecimalTests(tests, One, []string{"0.0~1.5"})

tests = appendIntegerTests(tests, Other, []string{"2~17", "100", "1000", "10000", "100000", "1000000"})
tests = appendDecimalTests(tests, Other, []string{"2.0~3.5", "10.0", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})

locales := []string{"pt"}
for _, locale := range locales {
runTests(t, locale, tests)
}
}

func TestAstCaDeEnEtFiFyGlItJiNlSvSwUrYi(t *testing.T) {
var tests []pluralTest

Expand Down Expand Up @@ -105,21 +120,6 @@ func TestTzm(t *testing.T) {
}
}

func TestPt(t *testing.T) {
var tests []pluralTest

tests = appendIntegerTests(tests, One, []string{"0", "1"})
tests = appendDecimalTests(tests, One, []string{"0.0", "1.0", "0.00", "1.00", "0.000", "1.000", "0.0000", "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{"pt"}
for _, locale := range locales {
runTests(t, locale, tests)
}
}

func TestAfAsaAzBemBezBgBrxCeCggChrCkbDvEeElEoEsEuFoFurGswHaHawHuJgoJmcKaKajKcgKkKkjKlKsKsbKuKyLbLgMasMgoMlMnNahNbNdNeNnNnhNoNrNyNynOmOrOsPapPsRmRofRwkSaqSdhSehSnSoSqSsSsyStSyrTaTeTeoTigTkTnTrTsUgUzVeVoVunWaeXhXog(t *testing.T) {
var tests []pluralTest

Expand All @@ -135,20 +135,6 @@ func TestAfAsaAzBemBezBgBrxCeCggChrCkbDvEeElEoEsEuFoFurGswHaHawHuJgoJmcKaKajKcgK
}
}

func TestPt_PT(t *testing.T) {
var tests []pluralTest

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

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{"pt_PT"}
for _, locale := range locales {
runTests(t, locale, tests)
}
}

func TestDa(t *testing.T) {
var tests []pluralTest

Expand Down Expand Up @@ -590,7 +576,7 @@ func TestGv(t *testing.T) {
}
}

func TestAr(t *testing.T) {
func TestArArs(t *testing.T) {
var tests []pluralTest

tests = appendIntegerTests(tests, Zero, []string{"0"})
Expand All @@ -611,7 +597,7 @@ func TestAr(t *testing.T) {
tests = appendIntegerTests(tests, Other, []string{"100~102", "200~202", "300~302", "400~402", "500~502", "600", "1000", "10000", "100000", "1000000"})
tests = appendDecimalTests(tests, Other, []string{"0.1~0.9", "1.1~1.7", "10.1", "100.0", "1000.0", "10000.0", "100000.0", "1000000.0"})

locales := []string{"ar"}
locales := []string{"ar", "ars"}
for _, locale := range locales {
runTests(t, locale, tests)
}
Expand Down
27 changes: 5 additions & 22 deletions i18n/language/pluralspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestGetPluralSpec(t *testing.T) {
{"zh-TW", pluralSpecs["zh"]},
{"pt-BR", pluralSpecs["pt"]},
{"pt_BR", pluralSpecs["pt"]},
{"pt-PT", pluralSpecs["pt-pt"]},
{"pt_PT", pluralSpecs["pt-pt"]},
{"pt-PT", pluralSpecs["pt"]},
{"pt_PT", pluralSpecs["pt"]},
{"zh-Hans-CN", pluralSpecs["zh"]},
{"zh-Hant-TW", pluralSpecs["zh"]},
{"zh-CN", pluralSpecs["zh"]},
Expand Down Expand Up @@ -462,11 +462,11 @@ func TestPortuguese(t *testing.T) {
{"0.0", One},
{1, One},
{"1.0", One},
{onePlusEpsilon, Other},
{onePlusEpsilon, One},
{2, Other},
}
tests = appendFloatTests(tests, 0.1, 0.9, Other)
tests = appendFloatTests(tests, 1.1, 10.0, Other)
tests = appendFloatTests(tests, 0, 1.5, One)
tests = appendFloatTests(tests, 2, 10.0, Other)
runTests(t, "pt", tests)
}

Expand All @@ -484,23 +484,6 @@ func TestMacedonian(t *testing.T) {
runTests(t, "mk", tests)
}

func TestPortugueseEuropean(t *testing.T) {
tests := []pluralTest{
{0, Other},
{"0.0", Other},
{"0.1", Other},
{"0.01", Other},
{1, One},
{"1", One},
{"1.1", Other},
{"1.01", Other},
{onePlusEpsilon, Other},
{2, Other},
}
tests = appendFloatTests(tests, 2.0, 10.0, Other)
runTests(t, "pt-pt", tests)
}

func TestRussian(t *testing.T) {
tests := []pluralTest{
{0, Many},
Expand Down

0 comments on commit ca33e78

Please sign in to comment.