Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CookieOptions ¶
type CookieOptions struct {
// Name is the name of the cookie. Default is "lang".
Name string
// Path is the Path attribute of the cookie. Default is "/".
Path string
// Domain is the Domain attribute of the cookie. Default is not set.
Domain string
// MaxAge is the MaxAge attribute of the cookie. Default is math.MaxInt.
MaxAge int
// Secure specifies whether to set Secure for the cookie.
Secure bool
// HTTPOnly specifies whether to set HTTPOnly for the cookie.
HTTPOnly bool
// SameSite is the SameSite attribute of the cookie. Default is
// http.SameSiteLaxMode.
SameSite http.SameSite
}
CookieOptions contains options for setting HTTP cookies.
type Language ¶
type Language struct {
// Name is the BCP 47 language name, e.g. "en-US".
Name string
// Description is the descriptive name of the language, e.g. "English".
Description string
}
Language contains the name and description of a language.
type Locale ¶
type Locale interface {
// Lang returns the BCP 47 language name of the locale.
Lang() string
// Description returns the descriptive name of the locale.
Description() string
// Translate translates the message of the given key. It falls back to use the
// "Default" to translate if the given key does not exist in the current locale.
Translate(key string, args ...interface{}) string
}
Locale is the message translator of a language.
type Options ¶
type Options struct {
// FileSystem is the interface for supporting any implementation of the
// http.FileSystem.
FileSystem http.FileSystem
// Directory is the primary directory to load locale files. This value is
// ignored when FileSystem is set. Default is "locales".
Directory string
// AppendDirectories is a list of additional directories to load locale files
// for overwriting locale files that are loaded from FileSystem or Directory.
AppendDirectories []string
// Languages is the list of languages to load locale files for.
Languages []Language
// Default is the name of the default language to fall back for missing
// translations. Default is the first element of Languages.
Default string
// NameFormat is the name format of locale files. Default is "locale_%s.ini".
NameFormat string
// QueryParameter is the name of the URL query parameter to accept language
// override. Default is "lang".
QueryParameter string
// Cookie is a set of options for setting HTTP cookies.
Cookie CookieOptions
}
Options contains options for the i18n.I18n middleware.
Click to show internal directories.
Click to hide internal directories.