Documentation
¶
Overview ¶
Package i18n provides lightweight internationalization for the DWS CLI.
At startup call Init() (or let the package auto-init via the init function). Use T("key") to get a translated string, or Tf("key", args...) for formatted translations with fmt.Sprintf-style placeholders.
The active language is resolved from the DWS_LANG environment variable first, then falls back to the LANG environment variable. If neither is set or does not match a supported locale, "en" (English) is used as the default.
Message catalogs are stored as JSON files under locales/ and embedded at compile time via go:embed.
Supported locales:
- "en" — English (default)
- "zh" — Simplified Chinese
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init()
Init resolves the active locale from environment variables and loads the message catalogs from embedded JSON files. Safe to call multiple times; only the first call takes effect.
Types ¶
This section is empty.