Documentation ¶
Index ¶
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 implements the Localizer interface
func (*I18n) LoadJSONLocalesFromFolder ¶
LoadJSONLocalesFromFolder Parses and Loads all the locales in json format in a folder (filename is used as the key of the locale. Ex: en.json -> "en", de.json -> "de")
func (*I18n) Translator ¶
func (l *I18n) Translator(localeKey string) Translator
Translator Returns a translator for the locale. If no locale is added, it returns an empty translator
type I18nTranslator ¶
type I18nTranslator struct {
// contains filtered or unexported fields
}
I18nTranslator implements the Translator interface
func (*I18nTranslator) Tr ¶
func (t *I18nTranslator) Tr(key string, args ...interface{}) string
Tr Translates a key. Format the string using additional parameters
type Localizer ¶
type Localizer interface { AddLocale(localeKey string, translations map[string]string) Translator(localeKey string) Translator LoadJSONLocalesFromFolder(localesPath string) error }
Localizer defines the interface for a localizer
func Get ¶
func Get() Localizer
Get returns a singleton localizer if you need a plug and play option We dont need a thread safe singleton in most cases as we dont change any data once loaded. So it is not thread safe
func NewLocalizer ¶
func NewLocalizer() Localizer
NewLocalizer Returns a new localizer which carries translations from the given locale path
type Translator ¶
Translator defines the interface for a translator