loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(i18n): make HasKey aware of newStyleMessages (#7166)

Followup to https://codeberg.org/forgejo/forgejo/pulls/6203
Related to https://codeberg.org/forgejo/forgejo/pulls/6154

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7166
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>

authored by

0ko
0ko
and committed by
Gusted
3db9de3b eb78c661

+13 -1
+9 -1
modules/translation/i18n/i18n_test.go
··· 156 156 assert.ElementsMatch(t, []string{"lang1", "lang2"}, langs) 157 157 assert.ElementsMatch(t, []string{"Lang1", "Lang2"}, descs) 158 158 159 - found := lang1.HasKey("no-such") 159 + // Test HasKey for JSON 160 + found := lang2.HasKey("section.json") 161 + assert.True(t, found) 162 + 163 + // Test HasKey for INI 164 + found = lang2.HasKey("section.sub") 165 + assert.True(t, found) 166 + 167 + found = lang1.HasKey("no-such") 160 168 assert.False(t, found) 161 169 assert.EqualValues(t, "no-such", lang1.TrString("no-such")) 162 170 require.NoError(t, ls.Close())
+4
modules/translation/i18n/localestore.go
··· 303 303 304 304 // HasKey returns whether a key is present in this locale or not 305 305 func (l *locale) HasKey(trKey string) bool { 306 + _, ok := l.newStyleMessages[trKey] 307 + if ok { 308 + return true 309 + } 306 310 idx, ok := l.store.trKeyToIdxMap[trKey] 307 311 if !ok { 308 312 return false