i18n

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detect

func Detect() string

Detect returns the locale string using this priority: 1. VMINFO_LANG env var 2. LANG / LC_ALL system locale 3. Default "en"

Types

type Translator

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

Translator provides lightweight string translation. Keys are English text; missing keys fall back to the key itself.

func New

func New(locale string) *Translator

New creates a Translator for the given locale (e.g. "en", "zh"). If the locale has no translation file, all lookups fall back to the key.

func (*Translator) Locale

func (t *Translator) Locale() string

Locale returns the current locale code (e.g. "en", "zh").

func (*Translator) T

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

T returns the translated string for key, or key itself as fallback.

func (*Translator) Tf

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

Tf returns fmt.Sprintf(T(key), args...).

Jump to

Keyboard shortcuts

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