i18n

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
const Default = "en"

Default is the fallback language.

Variables

View Source
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).

View Source
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

func Canonical(tag string) (string, bool)

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

func FormatCompactInt(lang string, n int64) string

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 FormatInt

func FormatInt(lang string, n int64) string

FormatInt renders n with locale-appropriate digit grouping.

func FormatPercent

func FormatPercent(lang string, ratio float64) string

FormatPercent renders a 0..1 ratio as a whole percentage with the locale's spacing convention.

func Has

func Has(lang string) bool

Has reports whether lang is a supported locale (exact code).

func Keys

func Keys(lang string) []string

Keys returns the sorted key set of a locale (mainly for tests).

func Match

func Match(acceptLanguage string) string

Match negotiates a locale from an Accept-Language header value, honoring q-values, defaulting to English.

func T

func T(lang, key string, args ...any) string

T resolves key in lang, falling back to English, then to the key itself (visible and greppable rather than silently blank). When args are given the message is treated as a Sprintf format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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