Documentation
¶
Overview ¶
Package i18n gives Ken's human web UI runtime-reloadable, drop-in translations.
English (locales/messages.properties) ships embedded as the default AND the fallback; Spanish (locales/messages_es.properties) ships too. To add or override a language, drop a `messages_<lang>.properties` file into the external i18n dir (KEN_I18N_DIR, default <data-dir>/i18n) — it is picked up at runtime, no recompile and no restart (changes are noticed within a couple of seconds).
File format: UTF-8, `key = value`, `#`/`!` comments, blank lines ignored, `{0}` `{1}` … positional placeholders, and the usual `\n \t \\ \uXXXX` escapes. Each file declares its own endonym via the reserved key `lang.self_name` (shown in the language selector). A missing key falls back to English, then to the key itself (so gaps are visible, never blank). Scope: the human web UI only — the AI/MCP surface and the server logs stay English.
Index ¶
Constants ¶
const (
// DefaultLang is the built-in default and the fallback for any missing key.
DefaultLang = "en"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds the merged catalogs (embedded defaults overlaid with the external override dir) and reloads the external dir when its files change.
func New ¶
New builds a Manager, loading the embedded defaults and overlaying dir if it exists. dir need not exist yet — it is watched and picked up when created.
func (*Manager) Languages ¶
Languages returns the available languages (English first, then alphabetical) — the list the UI language selector renders.
func (*Manager) MaybeReload ¶
func (m *Manager) MaybeReload()
MaybeReload re-reads the external dir if its files changed since the last check (throttled). Call once per request, not per T.
func (*Manager) T ¶
T translates key in lang, substituting {0}, {1}, … with args. Falls back to English, then to the key itself. Safe for concurrent use.