MustLocalize panics even when DefaultMessage is specified
Kichiyaki opened this issue · comments
Version: 2.1.1
Code:
const InternalServerError = "internalServerError"
func FallbackMsg(id string, msg string) *i18n.Message {
return &i18n.Message{
ID: id,
One: msg,
Many: msg,
Other: msg,
}
}
localizer.MustLocalize(&i18n.LocalizeConfig{
MessageID: InternalServerError,
DefaultMessage: FallbackMsg(InternalServerError,
"{{.Mention}} Internal server error occurred, please try again later."),
TemplateData: map[string]interface{}{
"Mention": "Adam",
},
})
Error: message "internalServerError" not found in language "language tag"
In the older version (v2.0.3) everything works fine, something is wrong with the update.
Yeah, there is a behavior change here. It is now considered an error if we fallback to a language that wasn't requested by the client. If you don't want this to be an error, then you can include the default locale in the call to NewLocalizer.