lang

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recognized added in v1.6.0

func Recognized(code string) bool

Recognized is the exported form of recognized, for callers that validate a language value before storing it (e.g. `config set output.lang`).

func UICatalogFor added in v1.6.0

func UICatalogFor(raw string) string

UICatalogFor maps a raw language value (e.g. a --lang flag) to the interface catalog code to load: the value itself when we ship a catalog for it, else English. Used by early-error paths that have a raw flag but no resolved Resolution yet.

Types

type Resolution

type Resolution struct {
	Code   string
	Name   string
	Source Source
}

Resolution is the outcome of the language chain. Code is the resolved language and drives the AI **output** language verbatim (so an output-only language like "fr" is preserved). Name is its display name for the prompt directive. Source records which step of the chain decided it, for dry-run and verbose-footer attribution.

The CLI **interface** language is derived separately via UICatalog(): the output language and the interface language share one resolution but the interface only localizes to languages we ship a catalog for.

func English added in v1.6.0

func English() Resolution

English is the terminal fallback of the chain, and a convenience constructor for callers that always want English output (e.g. the eval harness, which pins fixtures to a deterministic language).

func Resolve

func Resolve(flag string, repo, global *config.Config) Resolution

Resolve walks the language source chain and returns the resolved output language:

--lang flag → repo config (output.lang) → user config (output.lang) → English

At every step a value that is empty OR not a recognized language falls through to the next source — it never short-circuits to English mid-chain. The system locale (LANG env var) is deliberately NOT consulted: language is config-driven only (ADR-0021, superseding the D-21 / UC-09 env-LANG step).

flag is the raw `--lang` value ("" when the flag was not passed). repo and global are the raw per-file configs (config.LoadFile, not the merged config) so each level is judged on its own stated value.

func (Resolution) UICatalog added in v1.6.0

func (r Resolution) UICatalog() string

UICatalog returns the language code to load CLI interface strings for: the resolved code when we ship a catalog for it (en, tr), otherwise English. This is what makes `--lang fr` produce French *output* while the CLI's own chrome stays English — the two are resolved from the same chain but the interface degrades to English for any language we haven't translated.

type Source

type Source int
const (
	SourceDefault Source = iota
	SourceGlobalConfig
	SourceRepoConfig
	// SourceCLIFlag is the highest-priority step in the resolution chain:
	// an explicit `--lang` on the command line wins over both config files.
	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