locale

package
v0.2.0-rc.16 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultLocale = "en"

Variables

View Source
var SupportedLocales = []language.Tag{
	language.English,
	language.Polish,
}

SupportedLocales defines all locales that the application supports

Functions

func Normalize

func Normalize(locale string) string

Normalize ensures a locale string is in a standard BCP 47 format. It parses, canonicalizes, and matches against supported locales. If the locale is not supported, returns the closest match or default.

func ParseAcceptLanguage

func ParseAcceptLanguage(acceptLanguage string) string

ParseAcceptLanguage parses the Accept-Language header and returns the most preferred supported locale as a BCP 47 language tag string (e.g., "en", "en-US", "pl", "de-DE"). It uses golang.org/x/text/language for proper RFC 4647 parsing and matching. If the user's desired language is not supported, it finds the closest match. If no suitable match is found, it returns the default locale "en".

Types

This section is empty.

Jump to

Keyboard shortcuts

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