chore: form binding trim space (#38978)

Use "binding:TrimSpace" instead of fragile IsEmptyString

And fix a bug in locale's `HasKey`: it should also try the default
language if current language doesn't have the translation key, a new
test is added.
This commit is contained in:
wxiaoguang
2026-08-19 20:50:06 +08:00
committed by GitHub
parent c121f02a7e
commit f261adb53f
17 changed files with 21 additions and 71 deletions
+4
View File
@@ -16,6 +16,7 @@ func TestLocaleStore(t *testing.T) {
{
".dot.name": "Dot Name",
"fmt": "%[1]s %[2]s",
"only_in_default": "",
"section.sub": "Sub String",
"section.mixed": "test value; <span style=\"color: red; background: none;\">%s</span>"
@@ -60,6 +61,9 @@ func TestLocaleStore(t *testing.T) {
found := lang1.HasKey("no-such")
assert.False(t, found)
found = lang2.HasKey("only_in_default")
assert.True(t, found)
assert.NoError(t, ls.Close())
res := lang1.TrHTML("<no-such>")
+3
View File
@@ -177,5 +177,8 @@ func (l *locale) HasKey(trKey string) bool {
return false
}
_, ok = l.idxToMsgMap[idx]
if !ok {
_, ok = l.store.localeMap[l.store.defaultLang]
}
return ok
}