Open adhatama opened 6 years ago
Hi, looking at CLDR document https://github.com/theplant/cldr#how-to-use, I think we need to import locale files.
These worked for me with en
locale:
lang/en.yaml
en:
demo:
plural: '{{p "Count" (one "{{.Count}} item") (other "{{.Count}} items")}}'
main.go
package main
import (
"fmt"
"github.com/qor/i18n"
"github.com/qor/i18n/backends/yaml"
_ "github.com/theplant/cldr/resources/locales" // this one!
)
func main() {
I18n := i18n.New(
yaml.New("lang"),
)
val := I18n.T(
"en",
"demo.plural",
map[string]int{"Count": 1},
)
fmt.Println(val)
}
Result:
$ go run main.go
1 item
However, I couldn't figure out how to use it with en-US
locale. It looks like CLDR has en
but not en-US
.
I have a simple pluralization like this:
The printed value of
val
is1 items
where it should be1 item
Did I miss something?