i18n

package
v6.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: AGPL-3.0, Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSupportedLocales

func GetSupportedLocales() map[string]string

GetSupportedLocales return a map of locale code and the file path with the translations

func InitTranslations

func InitTranslations(serverLocale, clientLocale string) error

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

func TranslationsPreInit(translationsDir string) error

TranslationsPreInit loads translations from filesystem if they are not loaded already and assigns english while loading server config

Types

type TranslateFunc

type TranslateFunc func(translationID string, args ...interface{}) string

TranslateFunc is the type of the translate functions

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

Jump to

Keyboard shortcuts

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