locale

package
v0.0.1 Latest Latest
Warning

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

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

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