Documentation ¶
Index ¶
- func Flag(languageCode string, parent bool) string
- func GetDefaultLanguage() string
- func GetDefaultTfunc() (i18n.TranslateFunc, error)
- func GetMascotFromRequest(c *gin.Context) string
- func GetMascotUrlFromRequest(c *gin.Context) string
- func GetParentTag(languageTag string) glang.Tag
- func GetTfuncAndLanguageFromRequest(c *gin.Context) (T i18n.TranslateFunc, Tlang *language.Language)
- func GetThemeFromRequest(c *gin.Context) string
- func InitI18n(conf config.I18nConfig, retriever UserRetriever) error
- func TfuncAndLanguageWithFallback(language string, languages ...string) (i18n.TranslateFunc, *language.Language, error)
- func Translate(languageCode string, to string) string
- type Language
- type Languages
- type TemplateTfunc
- type UserRetriever
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Flag ¶
Flag reads the language's country code and return the country's flag if national true or the international flag for the language
func GetDefaultLanguage ¶
func GetDefaultLanguage() string
GetDefaultLanguage : returns the default language from config
func GetDefaultTfunc ¶
func GetDefaultTfunc() (i18n.TranslateFunc, error)
GetDefaultTfunc : Gets T func from default language
func GetMascotFromRequest ¶
GetMascotFromRequest : Gets the user selected theme from the request
func GetMascotUrlFromRequest ¶
GetMascotUrlFromRequest : Get the user selected mascot url from the request. Returns an empty string if not set.
func GetParentTag ¶
GetParentTag returns the highest parent of a language (e.g. fr-fr -> fr)
func GetTfuncAndLanguageFromRequest ¶
func GetTfuncAndLanguageFromRequest(c *gin.Context) (T i18n.TranslateFunc, Tlang *language.Language)
GetTfuncAndLanguageFromRequest : Gets the T func and chosen language from the request
func GetThemeFromRequest ¶
GetThemeFromRequest : Gets the user selected theme from the request
func InitI18n ¶
func InitI18n(conf config.I18nConfig, retriever UserRetriever) error
InitI18n : Initialize the languages translation
func TfuncAndLanguageWithFallback ¶
func TfuncAndLanguageWithFallback(language string, languages ...string) (i18n.TranslateFunc, *language.Language, error)
TfuncAndLanguageWithFallback : When go-i18n finds a language with >0 translations, it uses it as the Tfunc However, if said language has a missing translation, it won't fallback to the "main" language
Types ¶
type Language ¶
type Languages ¶
type Languages []Language
func GetAvailableLanguages ¶
func GetAvailableLanguages() Languages
GetAvailableLanguages : Get languages available on the website, languages are parsed once at runtime
func ParseLanguages ¶
ParseLanguages takes a list of language codes and convert them in languages object
type TemplateTfunc ¶
TemplateTfunc : T func used in template
func GetTfuncFromRequest ¶
func GetTfuncFromRequest(c *gin.Context) TemplateTfunc
GetTfuncFromRequest : Gets the T func from the request