We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a simple pluralization like this:
lang/en-US.yml en-US: demo: plural: '{{p "Count" (one "{{.Count}} item") (other "{{.Count}} items")}}'
main.go I18n := i18n.New( yaml.New("lang"), ) val := I18n.T( "en-US", "demo.plural", map[string]int{"Count": 1}, ) fmt.Println(val)
The printed value of val is 1 items where it should be 1 item Did I miss something?
val
1 items
1 item
The text was updated successfully, but these errors were encountered:
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:
en
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.
en-US
Sorry, something went wrong.
No branches or pull requests
I have a simple pluralization like this:
The printed value of
val
is1 items
where it should be1 item
Did I miss something?
The text was updated successfully, but these errors were encountered: