lang

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: GPL-3.0 Imports: 2 Imported by: 0 modules, 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env struct {
	LANG string
}

type Resolution

type Resolution struct {
	Code   string
	Name   string
	Source Source
}

func CoerceCLIFlag added in v0.9.2

func CoerceCLIFlag(raw string) Resolution

CoerceCLIFlag turns a raw --lang value into a Resolution tagged with SourceCLIFlag, applying the same UC-09 coercion as Resolve so an unsupported code does not bypass the supported() filter just because the user passed it on the command line.

func Resolve

func Resolve(repo, global *config.Config, env Env) Resolution

Resolve walks the D-21 source chain (repo config → global config → LANG env → built-in default) and returns the active locale.

UC-09: when the resolved code is not one we ship a catalog for, we silently coerce it to "en" while keeping the original Source so dry-run and verbose-footer attribution still reflect *where* the choice came from. Erroring or warning loudly would punish users with legitimate non-en locales (LANG=de_DE.UTF-8 on a developer laptop) — silent coerce keeps the CLI usable and matches the existing i18n.Load fallback semantics one layer below.

type Source

type Source int
const (
	SourceDefault Source = iota
	SourceEnvLANG
	SourceGlobalConfig
	SourceRepoConfig
	// SourceCLIFlag is the highest-priority step in the D-21 chain: when the
	// user explicitly passes --lang on the command line, that wins over all
	// other sources. Resolve() does not return it directly (it has no access
	// to flags); callers apply the override after Resolve() and stamp this
	// Source so dry-run and verbose footer attribution stay accurate.
	SourceCLIFlag
)

func (Source) String

func (s Source) String() string

Jump to

Keyboard shortcuts

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