This is a **grammar engine** — it provides primitives for composing and reversing grammatically correct text. It is NOT a translation file manager. Consumers bring their own translations.
If you flatten this to `"gram.verb.delete.past": "deleted"`, the grammar engine breaks silently. **This is the #1 cause of agent-introduced bugs.** The loader's `flattenWithGrammar()` relies on path prefixes (`gram.verb.*`, `gram.noun.*`, etc.) to route objects into typed Go structs. Flattening bypasses this routing and causes silent data loss.
### This library does not manage consumer translations
go-i18n provides grammar primitives. Apps using it (core/cli, etc.) manage their own translation files. Do not add app-specific translation keys to `locales/en.json` — only `gram.*` grammar data belongs there.
The root package uses a **singleton + instance** pattern. Package-level functions (`T()`, `PastTense()`, `SetLanguage()`, etc.) delegate to a default `Service` stored in an `atomic.Pointer`. `NewService()` creates instances; `SetDefault()` installs one as the package-level singleton. The `Service` holds the message store, grammar cache, key handlers, and language state.
### Three-Tier Grammar Lookup
Every grammar primitive follows the same resolution order:
1. JSON grammar tables (`gram.verb`, `gram.noun`) loaded for the current language
2. Go built-in irregular maps (`irregularVerbs`, `irregularNouns`) — English only
3. Regular morphological rules (algorithmic) — English only
Non-English languages must provide comprehensive JSON tables since tiers 2 and 3 are English-only fallbacks.
### Key Handler Chain
`T(key, args...)` passes keys through registered `KeyHandler` implementations before falling back to the message store. The built-in `i18n.*` namespace auto-composes output (e.g., `i18n.progress.build` → `"Building..."`, `i18n.done.delete` → `"File deleted"`).