mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-21 16:50:49 +00:00
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:
@@ -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>")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user