Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LanguageMiddleware ¶
LanguageMiddleware inserts the language.Tag into the request context according to "Accept-Language" header
Usage:
func main() { // Assuming the package name where the generated locales are is "i18n" mux := LanguageMiddleware(i18n.Matcher)(http.DefaultServeMux) //... }
func WithLanguage ¶
WithLanguage injects the language.Tag into the context
If the provided value is not a valid language according to language.Parse, an empty value with be injected, in which case creating a locale with the ctx will result in the default tag being used.
func WithLanguageString ¶
WithLanguageString injects the language.Tag corresponding to the given string into the context
Refer to WithLanguage for more info.
Types ¶
type Matcher ¶ added in v0.3.2
type Matcher struct {
// contains filtered or unexported fields
}
func NewMatcher ¶ added in v0.3.2
func NewMatcher(supported []language.Tag, opts ...language.MatchOption) *Matcher
Click to show internal directories.
Click to hide internal directories.