i18n

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllMessages

func AllMessages() map[string]map[string]string

AllMessages returns message maps for all supported languages. Used to send both languages to the dashboard for client-side switching.

func DetectCLI

func DetectCLI() string

DetectCLI detects language from environment variables (LANG, LC_ALL, LC_MESSAGES). Returns "ja" for Japanese, "en" for everything else.

func DetectHTTP

func DetectHTTP(acceptLang string) string

DetectHTTP detects language from an Accept-Language header value. Returns "ja" for Japanese, "en" for everything else.

func Init

func Init()

Init detects the CLI language from environment variables and loads messages. Safe to call multiple times; detection runs only once.

func Lang

func Lang() string

Lang returns the current language code.

func Messages

func Messages(lang string) map[string]string

Messages returns the full message map for the given language. Used to inject translations into dashboard templates as JSON.

func SetLang

func SetLang(lang string)

SetLang explicitly sets the active language ("en", "ja").

func T

func T(key string) string

T returns the translated string for the given key. Fallback order: current language -> "en" -> key itself.

func Tf

func Tf(key string, args ...any) string

Tf returns a formatted translated string using fmt.Sprintf.

Types

This section is empty.

Jump to

Keyboard shortcuts

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