Documentation ¶
Index ¶
- type I18n
- func (i *I18n) JSON(code string) []byte
- func (i *I18n) Load(b []byte, isDefault bool) error
- func (i *I18n) Name(code string) string
- func (i *I18n) ParseLanguage(acceptLanguage string) string
- func (i *I18n) T(code, key string) string
- func (i *I18n) Tag(code string) language.Tag
- func (i *I18n) Tc(code, key string, n int) string
- func (i *I18n) Ts(code, key string, params ...string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I18n ¶
type I18n struct {
// contains filtered or unexported fields
}
I18n offers translation functions over different languages.
func (*I18n) Load ¶
Load loads a JSON language map into the instance overwriting existing keys that conflict.
func (*I18n) ParseLanguage ¶
ParseLanguage parses the language string and returns the locale code.
func (*I18n) Tc ¶
Tc returns the translation for the given key similar to vue i18n's tc(). It expects the language string in the map to be of the form `Singular | Plural` and returns `Plural` if n > 1, or `Singular` otherwise.
func (*I18n) Ts ¶
Ts returns the translation for the given key similar to vue i18n's t() and substitutes the params in the given map in the translated value. In the language values, the substitutions are represented as: {key} The params and values are received as a pairs of succeeding strings. That is, the number of these arguments should be an even number. eg: Ts("globals.message.notFound",
"name", "notes", "error", err)