Documentation
¶
Overview ¶
Package i18n is the website message catalog for the nine Public v1 locales (plan Global Constraints + P6.3). Catalogs are embedded JSON maps of key → translated string; English is the reference catalog and the fallback for any unknown language or missing key.
Only UI strings are translated. Data values — package names, versions, context labels like "node 22", confidence values, error codes — stay exactly as aggregated.
Index ¶
- Constants
- Variables
- func Canonical(tag string) (string, bool)
- func FormatCompactInt(lang string, n int64) string
- func FormatInt(lang string, n int64) string
- func FormatPercent(lang string, ratio float64) string
- func Has(lang string) bool
- func Keys(lang string) []string
- func Match(acceptLanguage string) string
- func T(lang, key string, args ...any) string
Constants ¶
const Default = "en"
Default is the fallback language.
Variables ¶
var NativeName = map[string]string{
"en": "English",
"ko": "한국어",
"ja": "日本語",
"zh-CN": "简体中文",
"es": "Español",
"fr": "Français",
"de": "Deutsch",
"pt-BR": "Português (Brasil)",
"ru": "Русский",
}
NativeName maps a locale to its own-language display name for the language switcher (a language name is data, not UI copy).
var Supported = []string{"en", "ko", "ja", "zh-CN", "es", "fr", "de", "pt-BR", "ru"}
Supported lists the nine Public v1 locales in switcher display order.
Functions ¶
func Canonical ¶
Canonical maps a user-supplied language tag to a supported locale: exact (case-insensitive) match first, then base-language match with zh→zh-CN and pt→pt-BR region defaults.
func FormatCompactInt ¶ added in v0.1.6
FormatCompactInt shortens large counters for prominent UI while keeping one useful decimal place (17,500 -> 17.5K). Callers that display this value must keep FormatInt available as the exact, accessible value.
func FormatPercent ¶
FormatPercent renders a 0..1 ratio as a whole percentage with the locale's spacing convention.
Types ¶
This section is empty.