feat(04-02): apply locale fallback and missing-key logging

- Resolve pl-PL then parent then app.fallback_locale then the raw key
- Read towel.Locale from request context and default app.locale/fallback to en
- Log each missing key once outside production and never log parameters

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-18 13:52:42 +02:00
parent 6d8786a2af
commit 8a4e0ef79b
3 changed files with 130 additions and 4 deletions

View File

@@ -130,6 +130,16 @@ func TestHelloPluginResolvesLang(t *testing.T) {
if got := tr.GetIn("en", "golem15.hello::lang.greeting", nil); got != "Hello" {
t.Fatalf("greeting = %q", got)
}
if got := tr.GetIn("pl-PL", "golem15.hello::lang.greeting", nil); got != "Cześć" {
t.Fatalf("pl-PL = %q", got)
}
if got := tr.GetIn("de", "golem15.hello::lang.greeting", nil); got != "Hello" {
t.Fatalf("fallback en = %q", got)
}
const missing = "golem15.hello::lang.does.not.exist"
if got := tr.GetIn("pl-PL", missing, nil); got != missing {
t.Fatalf("raw key = %q", got)
}
}
func TestTypedItemRoute(t *testing.T) {