i18n

package
v0.1.0-preview.4 Latest Latest
Warning

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

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

Documentation

Overview

Package i18n provides immutable, bounded message catalogs and deterministic HTTP language negotiation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is an immutable set of locale-keyed messages.

func ParseProperties

func ParseProperties(
	source fs.FS,
	pattern string,
	defaultLocale string,
) (*Catalog, error)

ParseProperties parses strict UTF-8 key=value .properties catalogs matched by pattern. The base filename is the default catalog; suffixed files such as messages_de.properties provide locale overrides.

func (*Catalog) Locales

func (catalog *Catalog) Locales() []string

Locales returns the supported locale identifiers in lexical order.

func (*Catalog) Message

func (catalog *Catalog) Message(locale, key string) (string, error)

Message returns a localized message, falling back to the default catalog when the selected locale does not override key.

func (*Catalog) Resolve

func (catalog *Catalog) Resolve(header string) string

Resolve selects a supported locale from an Accept-Language value. Invalid, oversized, or unmatched input deterministically falls back to the default.

Jump to

Keyboard shortcuts

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