nicksnyder / go-i18n

Translate your Go program into multiple languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error handling is faulty

yinchyu opened this issue · comments

 // 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

if err2 is not nil ,err=err2 ,but if err3 ==nil , fallback take effect , the err is not nil

This is intentional because a translation is missing in this case and go-i18n is returning a translation that is technically incorrect. Using the other translation is just a best effort instead of returning an empty string. If your code is hitting this condition, then you have a missing translation.

Duplicate of #241

thanks for your explanation