Reseting err to nil after falling back on Other plural form
salihzain opened this issue · comments
This package is awesome! Thanks for putting in all the efforts :)
I noticed that on lines 161 - 169 inside localizer.go
, the Localizer tries to fallback on the Other
plural form if for example few isn't found. Given the code:
// Attempt to fallback to "Other" pluralization in case translations are incomplete.
if pluralForm != plural.Other {
msg2, err3 := template.Execute(plural.Other, templateData, lc.Funcs)
if err3 == nil {
msg = msg2
}
}
return msg, tag, err
I noticed that if err3 == nil, the msg is set to msg2 but err isn't set to nil. So I'm getting back an error even though the localizer has correctly fallen back to the Other form. I'm wondering, is this the intended use of the package?
I wrote it this way intentionally, but I am open to feedback if this isn't intuitive. Right now go-i18n does its best to return a string, but if that string is grammatically wrong (because, for example, a translation is missing), then it will also return an error.
Makes total sense, thank you for the explanation @nicksnyder 👍