feat(build): lint-locale-usage should detect more Tr functions (#7278)
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Has been skipped
testing / frontend-checks (push) Has been skipped
testing / test-unit (push) Has been skipped
testing / test-e2e (push) Has been skipped
testing / test-mysql (push) Has been skipped
testing / test-pgsql (push) Has been skipped
testing / test-sqlite (push) Has been skipped
testing / test-remote-cacher (redis) (push) Has been skipped
testing / test-remote-cacher (valkey) (push) Has been skipped
testing / test-remote-cacher (garnet) (push) Has been skipped
testing / test-remote-cacher (redict) (push) Has been skipped
testing / security-check (push) Has been skipped

Followup to https://codeberg.org/forgejo/forgejo/pulls/7109

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7278
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Ellen Emilia Anna Zscheile <fogti+devel@ytrizja.de>
Co-committed-by: Ellen Emilia Anna Zscheile <fogti+devel@ytrizja.de>
This commit is contained in:
Ellen Emilia Anna Zscheile 2025-03-26 14:06:44 +00:00 committed by Gusted
parent e84d3a0f53
commit d0a5531ebc
3 changed files with 121 additions and 62 deletions

View file

@ -11,21 +11,27 @@ import (
"github.com/stretchr/testify/require"
)
func buildHandler(ret *[]string) Handler {
return Handler{
OnMsgid: func(fset *token.FileSet, pos token.Pos, msgid string) {
*ret = append(*ret, msgid)
},
OnUnexpectedInvoke: func(fset *token.FileSet, pos token.Pos, funcname string, argc int) {},
LocaleTrFunctions: InitLocaleTrFunctions(),
}
}
func HandleGoFileWrapped(t *testing.T, fname, src string) []string {
var ret []string
omh := OnMsgidHandler(func(fset *token.FileSet, pos token.Pos, msgid string) {
ret = append(ret, msgid)
})
require.NoError(t, omh.HandleGoFile(fname, src))
handler := buildHandler(&ret)
require.NoError(t, handler.HandleGoFile(fname, src))
return ret
}
func HandleTemplateFileWrapped(t *testing.T, fname, src string) []string {
var ret []string
omh := OnMsgidHandler(func(fset *token.FileSet, pos token.Pos, msgid string) {
ret = append(ret, msgid)
})
require.NoError(t, omh.HandleTemplateFile(fname, src))
handler := buildHandler(&ret)
require.NoError(t, handler.HandleTemplateFile(fname, src))
return ret
}