Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUserLocalesForContext ¶
GetUserLocalesForContext finds the user locales from the context.
func LocaleForContext ¶
LocaleForContext finds the locale from the context.
Types ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator handles translations
func NewTranslator ¶
func NewTranslator(path string, locales []string) *Translator
NewTranslator instanciates a new Translator struct. Locales should be passed by priority order. First locale will be the default one. First locale for a specific language will be the default for this language.
func (*Translator) Get ¶
func (t *Translator) Get(key string, locales []string) string
Get gets the translation for a given key and locales ordered by preference. The first match returns. Fallback to the default locale if the ones given does not exist
func (*Translator) GetForContext ¶
func (t *Translator) GetForContext(ctx context.Context, key string) string
GetForContext gets the translation for a given key and context. Same logic as Get().
Click to show internal directories.
Click to hide internal directories.