Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSupportedLocales ¶
GetSupportedLocales return a map of locale code and the file path with the translations
func InitTranslations ¶
InitTranslations set the defaults configured in the server and initialize the T function using the server default as fallback language
func TranslateAsHTML ¶
func TranslateAsHTML(t TranslateFunc, translationID string, args map[string]interface{}) template.HTML
TranslateAsHTML translates the translationID provided and return a template.HTML object
func TranslationsPreInit ¶
TranslationsPreInit loads translations from filesystem if they are not loaded already and assigns english while loading server config
Types ¶
type TranslateFunc ¶
TranslateFunc is the type of the translate functions
var T TranslateFunc
T is the translate function using the default server language as fallback language
var TDefault TranslateFunc
TDefault is the translate function using english as fallback language
func GetTranslationsAndLocaleFromRequest ¶
func GetTranslationsAndLocaleFromRequest(r *http.Request) (TranslateFunc, string)
GetTranslationsAndLocaleFromRequest return the translation function and the locale based on a request headers
func GetUserTranslations ¶
func GetUserTranslations(locale string) TranslateFunc
GetUserTranslations get the translation function for an specific locale
func IdentityTfunc ¶
func IdentityTfunc() TranslateFunc
IdentityTfunc returns a translation function that don't translate, only returns the same id