2019-12-13 22:06:18 +01:00
|
|
|
package context
|
|
|
|
|
|
|
|
import "golang.org/x/text/language"
|
|
|
|
|
|
|
|
// I18nReadOnly is the interface which ontains the read-only i18n features.
|
|
|
|
// Read the "i18n" package fo details.
|
|
|
|
type I18nReadOnly interface {
|
|
|
|
Tags() []language.Tag
|
2020-07-10 22:21:09 +02:00
|
|
|
GetLocale(ctx *Context) Locale
|
2019-12-13 22:06:18 +01:00
|
|
|
Tr(lang string, format string, args ...interface{}) string
|
|
|
|
}
|
|
|
|
|
2020-08-18 07:05:51 +02:00
|
|
|
// Locale is the interface which returns from a `Localizer.GetLocale` method.
|
|
|
|
// It serves the translations based on "key" or format. See `GetMessage`.
|
2019-12-13 22:06:18 +01:00
|
|
|
type Locale interface {
|
|
|
|
// Index returns the current locale index from the languages list.
|
|
|
|
Index() int
|
|
|
|
// Tag returns the full language Tag attached tothis Locale,
|
|
|
|
// it should be uniue across different Locales.
|
|
|
|
Tag() *language.Tag
|
|
|
|
// Language should return the exact languagecode of this `Locale`
|
|
|
|
//that the user provided on `New` function.
|
|
|
|
//
|
|
|
|
// Same as `Tag().String()` but it's static.
|
|
|
|
Language() string
|
2020-08-18 07:05:51 +02:00
|
|
|
// GetMessage should return translated text based on the given "key".
|
2019-12-13 22:06:18 +01:00
|
|
|
GetMessage(key string, args ...interface{}) string
|
2020-08-18 07:05:51 +02:00
|
|
|
// 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
|
2019-12-13 22:06:18 +01:00
|
|
|
}
|