I am doing some tests with the golang.org/x/text
package and particularly with the feature/plural
sub package and its MatchDigits
method. Here is what I am doing :
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
}
And here is where I get the expected results from : http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html#fr
I also tried with another language with more complex plural rules like Czech and the output was not correct.
Am I missing something ? I can not find a lot of examples on this package.
Thanks !
EDIT:
After some more tests, I found the good result for "1", using 0 as both the exp
and scale
parameters :
fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1}, 0, 0)) // prints 2 (One), the correct value
But it does not follow what the documentation says, and does not work when I try for 1,5 with the same logic :
fmt.Println(plural.Cardinal.MatchDigits(language.French, []byte{1, 5}, 0, 1)) // prints 0 (Other), should print 2 (One)