fix(html): honour locale in wasm translator
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f828848cc0
commit
9741659442
2 changed files with 24 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
15
default_translator_js_test.go
Normal file
15
default_translator_js_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue