Documentation
¶
Overview ¶
Package locales checks the content languages a site offers, such as "en" and "nl-BE", and writes their codes the same way everywhere. Which languages are enabled comes from a Provider, usually the Site settings; how a language shows in addresses, and the admin's own language, are decided elsewhere.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalid is returned for a language code that is not a valid BCP 47 // tag, such as "en_US" or an empty code. ErrInvalid = errors.New("invalid_locale") // ErrDisabled is returned for a valid language code that the site does // not offer. ErrDisabled = errors.New("locale_disabled") // ErrConfiguration is returned for a list of languages that cannot work: // none, more than 100, an invalid or repeated code, or a default that is // not one of them. ErrConfiguration = errors.New("invalid_locale_configuration") )
Functions ¶
Types ¶
type Config ¶
Config is the list of content languages: Default is the language a visitor gets when the address names none, and Enabled are all languages in the order editors and visitors see them, the default among them.
type Provider ¶
Provider gives the content languages, from the application's configuration or from the Site settings. Services ask for them in every operation, so a change in the settings takes effect at once.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a Provider with a fixed list of languages, checked once by New. Tests and tools use it where a site would pass its Site settings.