Error : "Missing pluralization rule for" for Lingo in Vapor

123 Views Asked by At

I'm using the Lingo package for my Vapor solution see : https://github.com/vapor-community/Lingo-Vapor and this has been working perfect for 3 languages

Now I need plurals for a popup I'm creating :

for i in stride(from: 1, to: 12, by: 1) {
            if let description = lingo?.localize("lbl_hour_s", locale: language, interpolations: ["count" : i]) {
                option = FormFieldStringOption(key:String(i), label: description)
            } else {
                option = FormFieldStringOption(key:String(i), label: String(i))
            }
            duration.options.append(option)
        }

My Json files are configured like this :

for en_US
"lbl_hour_s" : {"one" : "1 hour", "other" : "%{count} hours"},


for nl_BE
"lbl_hour_s" : {"one" : "%{count} uur", "many" : "%{count} uren", "other" : "%{count} uren"},

(I tried with the extra 'many' in nl, but still getting the same error in both cases :

Missing pluralization rule for locale: en_US. Will default to other rule.

Is there something wrong with this ? It looks the same as the example from the docs :

"unread.messages": {
        "one": "You have one unread message.",
        "other": "You have %{count} unread messages."

or do I need some extra configuration to Lingo ? (found nothing in the docs for it)

2

There are 2 best solutions below

1
On

I found my problem. I was using 'en_US' as I wanted to provide more translations in the future. Apparently for USA English I should use 'en'.

Had the same problem with 'nl_BE' the Dutch (Nederlands) spoken language in Belgium. I wanted this as I'm also adding 'nl_NL', the dutch spoken language in Holland. Both are 95% the same but some words or sentences are different.

1
On

The problem is that Lingo didn't automatically fall back to bare language code pluralization rules (eg. from en_US -> en when en_US doesn't exist).

This is fixed in version 3.1.0.