i18n

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package i18n translates the text the command line prints for a person: help, errors and status labels. Event messages, JSON output, config values, command and flag names stay English because scripts and docs/EVENT-KEYS.md depend on their exact text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init sets the language from the process environment.

func Lookup

func Lookup(key string) (string, bool)

Lookup returns the unformatted text for key.

func Set

func Set(language Language)

Set selects the output language.

func T

func T(key string, arguments ...any) string

T returns the text for key in the current language, formatted with arguments. A key missing from the language falls back to English; a key missing everywhere returns the key itself.

func Wrap

func Wrap(err error, key string, arguments ...any) error

Wrap returns err prefixed with the translated message for key.

Types

type Language

type Language string

Language is a supported output language.

const (
	English Language = "en"
	Russian Language = "ru"
)

func Current

func Current() Language

Current returns the selected language.

func Detect

func Detect(lookup func(string) string, systemLocale string) Language

Detect picks the output language. LLM_ROUTER_LANG wins, then the first non-empty of LC_ALL, LC_MESSAGES and LANG, then the system locale. Russian is chosen only for a "ru" language code; every other value, including C and POSIX, gives English.

Jump to

Keyboard shortcuts

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