go-i18n icon indicating copy to clipboard operation
go-i18n copied to clipboard

no plural rule registered for XX

Open bep opened this issue 5 years ago • 4 comments

I got an error report in Hugo:

no plural rule registered for oc

I was pretty sure I had a test for that, and I did.

What I currently do is something like this:

lang := "oc"
tag := language.Make(lang)
if tag == language.Und {
   name = "art-x-" + name
}
_, _ = bundle.ParseMessageFileBytes(b, name)

The above works fine for klingon, but not for oc (which is a valid language code).

I assume this is a data synch issue, but I don't know how to work around it.

/cc @digitalcraftsman

bep avatar Oct 08 '20 08:10 bep

I could proably check the error and try again.

bep avatar Oct 08 '20 08:10 bep

The latest CLDR data (v37) does not include a plural rule for oc.

Using art-x-oc should work. I verified this test still passes if I substitute art-x-oc for art-x-klingon.

nicksnyder avatar Oct 09 '20 05:10 nicksnyder

Using art-x-oc should work.

Sure, but having to do a "check if error string contains this magic string" and then do a retry isn't ... perfect.

bep avatar Oct 09 '20 07:10 bep

Currently for a locale to work with go-i18n, it must either:

  • Be supported by both https://pkg.go.dev/golang.org/x/text and have a plural rule defined in CLDR OR
  • Be an artificial language (e.g. art-x- prefix) (in which case it would use default pluralization rules, which might not be what is desired).

The real solution to this problem for a given locale is to submit an upstream change to add support for that new locale.

nicksnyder avatar Oct 15 '20 20:10 nicksnyder