1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-23 12:57:05 +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

@@ -7,7 +7,8 @@ import "golang.org/x/text/language"
type I18nReadOnly interface {
Tags() []language.Tag
GetLocale(ctx *Context) Locale
Tr(lang string, format string, args ...interface{}) string
Tr(lang string, key string, args ...interface{}) string
TrContext(ctx *Context, key string, args ...interface{}) string
}
// Locale is the interface which returns from a `Localizer.GetLocale` method.
@@ -25,10 +26,4 @@ type Locale interface {
Language() string
// GetMessage should return translated text based on the given "key".
GetMessage(key string, args ...interface{}) string
// GetMessageContext same as GetMessage
// but it accepts the Context as its first input.
// If DefaultMessageFunc was not nil then this Context
// will provide the real language input instead of the locale's which
// may be the default language one.
GetMessageContext(ctx *Context, key string, args ...interface{}) string
}