Documentation
¶
Overview ¶
Package i18n provides language detection, localization and a Gin middleware for selecting the request language.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lang ¶
type Lang struct {
// contains filtered or unexported fields
}
Lang resolves the active language from a context.
func NewDefault ¶
NewDefault builds a Lang with the default set of languages.
func (*Lang) GetDefaultLang ¶
GetDefaultLang returns the default language.
func (*Lang) GetLangFromContext ¶
GetLangFromContext returns the language stored in the context, or the default.
func (*Lang) GetLocalize ¶
GetLocalize returns the localizer for the context language.
func (*Lang) IsAvailableLang ¶
IsAvailableLang reports whether the language is supported. An empty string is treated as unsupported.
type Localize ¶
type Localize struct {
// contains filtered or unexported fields
}
Localize translates message ids for a single language.
func NewLocalize ¶
NewLocalize builds a localizer for the given languages.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware stores the request language in the context.
func NewMiddleware ¶
func NewMiddleware(settings Settings) *Middleware
NewMiddleware builds the middleware.
func (*Middleware) SetLanguage ¶
func (m *Middleware) SetLanguage(ctx *gin.Context)
SetLanguage extracts the language from the request and stores it in the context.
type Responder ¶
Responder exposes the translation bundle.
func NewResponder ¶
NewResponder builds a Responder.