i18n

package
v0.0.0-...-e2dd9e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2022 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSupportedLang

func GetSupportedLang(lang string) string

GetSupportedLang is a helper to check if language passed is supported by system

func GetSupportedLanguages

func GetSupportedLanguages() []string

GetSupportedLanguages get all system suported laguages codes

func NewBundle

func NewBundle() *i18n.Bundle

NewBundle create a singleton instance of *i18n.Bundle, who know where to look and find the translation files

func NewLocalizer

func NewLocalizer(lang, accept string) *i18n.Localizer

NewLocalizer create a new i18n localizer

func SetBody

func SetBody(c *context.Context, body gin.H, translations map[string]string) gin.H

func SetLang

func SetLang(c *context.Context, lang string) *context.Context

SetLang change the localizer context language

func Translate

func Translate(c *context.Context, id string) string

Translate is a shortcut for `c.Localizer.Localize(&i18n.LocalizeConfig{MessageID: id})` and also treat errors with default message

func TranslateNestedItem

func TranslateNestedItem(c *context.Context, nestedKey, id string) string

TranslateNestedItem is a shortcut for `Translate(c, fmt.Sprintf("%s.%s", nestedKey, id))`

func TranslatePageFull

func TranslatePageFull(c *context.Context, nestedKey string) (map[string]string, error)

TranslatePageFull retrive all nested traslation based on nestedKey

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL