i18n

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 5 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

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