i18n

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	English           = "en"
	SimplifiedChinese = "zh-CN"
)

Variables

This section is empty.

Functions

func Detect

func Detect(explicit, configured string, lookupEnv func(string) string) string

Detect chooses a locale using this priority: explicit, VMFLOW_LANG, configured, English.

func Match

func Match(value string) (string, bool)

Match normalizes a locale and reports whether vmflow supports it.

func SupportedLocales

func SupportedLocales() []string

SupportedLocales returns the canonical locale codes accepted by vmflow.

Types

type Translator

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

Translator resolves stable message keys for one locale. It is immutable after construction and can be passed safely to independent CLI or TUI runs.

func New

func New(locale string) *Translator

New creates a translator for locale. Unsupported locales use English.

func (*Translator) Locale

func (t *Translator) Locale() string

Locale returns the canonical locale code used by this translator.

func (*Translator) T

func (t *Translator) T(key string) string

T returns the localized value for key, falling back to English and then key.

func (*Translator) Tf

func (t *Translator) Tf(key string, args ...any) string

Tf formats the localized value for key with fmt.Sprintf.

Jump to

Keyboard shortcuts

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