“golang.org/x/text”内的复数包存在问题

jai*_*ons 5 internationalization go

我正在对golang.org/x/text包进行一些测试,特别是feature/plural对子包及其MatchDigits方法。这就是我正在做的事情:

package main

import (
    "fmt"

    "golang.org/x/text/feature/plural"
    "golang.org/x/text/language"
)

func main() {
    fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1}, 1, 0)) // "1" -> should print 2 (One) but prints 0 (Other)
    fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{2}, 1, 0)) // "2" -> prints 0 (Other) the correct value
    fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1, 0}, 2, 0)) // "10" -> prints 0 (Other) the correct value
}
Run Code Online (Sandbox Code Playgroud)

这是我从以下位置获得预期结果的地方:http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#fr

我还尝试了另一种具有更复杂复数规则的语言,例如捷克语,但输出不正确。

我错过了什么吗?我在这个包上找不到很多例子。

谢谢 !

编辑:

经过更多测试,我发现“1”的结果很好,使用 0 作为expscale参数:

fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1}, 0, 0)) // prints 2 (One), the correct value
Run Code Online (Sandbox Code Playgroud)

但它不遵循文档所说的,并且当我尝试使用相同的逻辑 1,5 时不起作用:

fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1, 5}, 0, 1)) // prints 0 (Other), should print 2 (One)
Run Code Online (Sandbox Code Playgroud)