locale

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

View Source
var Default = language.English

Default is used whenever no locale could be detected from the request.

Functions

func Detect

func Detect(r *http.Request) language.Tag

Detect parses the request's Accept-Language header and returns the best-matching language tag, or Default if none could be parsed.

func FromContext

func FromContext(ctx context.Context) language.Tag

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

func NewContext(ctx context.Context, tag language.Tag) context.Context

NewContext returns a copy of ctx carrying tag, retrievable via FromContext.

func SuggestCurrency

func SuggestCurrency(tag language.Tag) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL