fix(html): honour locale in wasm translator
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 00:38:33 +00:00
parent f828848cc0
commit 9741659442
2 changed files with 24 additions and 1 deletions

View file

@ -9,7 +9,15 @@ type defaultTranslator struct {
}
func (t *defaultTranslator) T(key string, args ...any) string {
_ = t.language
if key == "prompt.yes" {
switch t.language {
case "fr":
return "o"
case "en":
return "y"
}
}
if len(args) == 0 {
return key
}

View file

@ -0,0 +1,15 @@
//go:build js
// SPDX-Licence-Identifier: EUPL-1.2
package html
import "testing"
func TestDefaultTranslatorJS_AppliesLocale(t *testing.T) {
ctx := NewContext("fr-FR")
if got := Text("prompt.yes").Render(ctx); got != "o" {
t.Fatalf("Text(prompt.yes) with js default translator = %q, want %q", got, "o")
}
}