Documentation
¶
Overview ¶
Package locale detects a request's preferred locale from the browser's Accept-Language header and makes it available via context, for locale-aware formatting (view/ui) and currency suggestions (setup flow).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = language.English
Default is used whenever no locale could be detected from the request.
Functions ¶
func Detect ¶
Detect parses the request's Accept-Language header and returns the best-matching language tag, or Default if none could be parsed.
func FromContext ¶
FromContext returns the locale stored in ctx by the locale middleware, or Default if none is present (e.g. in tests or non-HTTP code paths).
func NewContext ¶
NewContext returns a copy of ctx carrying tag, retrievable via FromContext.
func SuggestCurrency ¶
SuggestCurrency returns the ISO 4217 currency code conventionally used in tag's region (e.g. "id-ID" → "IDR"), or "" if it can't be determined.
Types ¶
This section is empty.