1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

i18n: respect fallback language when Strict is false and no DefaultMessageFunc was provided

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-30 10:36:25 +03:00
parent 5b983800ec
commit 5017e3c986
4 changed files with 43 additions and 66 deletions

View File

@@ -1254,14 +1254,8 @@ func (ctx *Context) GetLocale() Locale {
// See `GetLocale` too.
//
// Example: https://github.com/kataras/iris/tree/master/_examples/i18n
func (ctx *Context) Tr(message string, values ...interface{}) string {
if locale := ctx.GetLocale(); locale != nil {
return locale.GetMessageContext(ctx, message, values...)
}
// This should never happen as the locale fallbacks to
// the default.
return message
func (ctx *Context) Tr(key string, args ...interface{}) string {
return ctx.app.I18nReadOnly().TrContext(ctx, key, args...)
}
// +------------------------------------------------------------+