i18n

package
v1.80.0-pref-login-name.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedLanguages

func SupportedLanguages(dir http.FileSystem) ([]language.Tag, error)

Types

type Message

type Message struct {
	ID   string
	Text string
}

type Translator

type Translator struct {
	// contains filtered or unexported fields
}

func NewTranslator

func NewTranslator(dir http.FileSystem, defaultLanguage language.Tag, cookieName string) (*Translator, error)

func (*Translator) AddMessages

func (t *Translator) AddMessages(tag language.Tag, messages ...Message) error

func (*Translator) Lang

func (t *Translator) Lang(r *http.Request) language.Tag

func (*Translator) Localize

func (t *Translator) Localize(id string, args map[string]interface{}, langs ...string) string

func (*Translator) LocalizeFromCtx

func (t *Translator) LocalizeFromCtx(ctx context.Context, id string, args map[string]interface{}) string

func (*Translator) LocalizeFromRequest

func (t *Translator) LocalizeFromRequest(r *http.Request, id string, args map[string]interface{}) string

func (*Translator) SetLangCookie

func (t *Translator) SetLangCookie(w http.ResponseWriter, r *http.Request, lang language.Tag)

func (*Translator) SetPreferredLanguages

func (t *Translator) SetPreferredLanguages(langs ...string)

func (*Translator) SupportedLanguages

func (t *Translator) SupportedLanguages() []language.Tag

type TranslatorConfig

type TranslatorConfig struct {
	DefaultLanguage language.Tag
	CookieName      string
}

Jump to

Keyboard shortcuts

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