fix(build): actually enforce masked prefixes verification in lint-locale-usage

This commit is contained in:
Ellen Emilia Anna Zscheile 2025-08-04 00:30:11 +02:00
commit f2bb2016e1
3 changed files with 52 additions and 4 deletions

View file

@ -13,6 +13,18 @@ gpg.error.failed_retrieval_gpg_keys
gpg.error.generate_hash gpg.error.generate_hash
gpg.error.no_committer_account gpg.error.no_committer_account
# models/actions/runner.go
actions.runners.status.
# models/actions/status.go, templates/repo/actions/status.tmpl
actions.status.
# models/git/commit_status.go
repo.commitstatus.
# models/issues/comment.go
repo.issues.role.
# models/system/notice.go: func (n *Notice) TrStr() string # models/system/notice.go: func (n *Notice) TrStr() string
admin.notices.type_1 admin.notices.type_1
admin.notices.type_2 admin.notices.type_2
@ -20,7 +32,20 @@ admin.notices.type_2
# modules/setting/ui.go # modules/setting/ui.go
themes.names. themes.names.
# modules/translation/translation.go
munits.data.
# modules/web/middleware/binding.go
form.
# routers/web/admin/admin.go
admin.dashboard.
# routers/web/repo/activity.go
repo.activity.period.
# routers/web/repo/helper.go: "repo.tree_path_not_found_"+refType # routers/web/repo/helper.go: "repo.tree_path_not_found_"+refType
repo.
repo.tree_path_not_found_branch repo.tree_path_not_found_branch
repo.tree_path_not_found_commit repo.tree_path_not_found_commit
repo.tree_path_not_found_tag repo.tree_path_not_found_tag
@ -28,6 +53,9 @@ repo.tree_path_not_found_tag
# services/context/context.go # services/context/context.go
relativetime. relativetime.
# services/cron/setting.go, templates/admin/cron.tmpl
admin.dashboard.
# templates/mail/issue/default.tmpl: $.locale.Tr # templates/mail/issue/default.tmpl: $.locale.Tr
mail.issue.in_tree_path mail.issue.in_tree_path
@ -37,9 +65,12 @@ repo.permissions.
# templates/package/metadata/arch.tmpl: $.locale.Tr # templates/package/metadata/arch.tmpl: $.locale.Tr
packages.details.license packages.details.license
# templates/repo/editor/commit_form.tmpl: ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .CanCommitToBranch.WontSignReason) # templates/repo/editor/commit_form.tmpl
repo.signing.wont_sign. repo.signing.wont_sign.
# templates/repo/issue/filter_list.tmpl, tests/integration/repo_test.go
repo.issues.filter_sort.
# templates/repo/issue/view_content.tmpl: indirection via $closeTranslationKey # templates/repo/issue/view_content.tmpl: indirection via $closeTranslationKey
repo.issues.close repo.issues.close
repo.pulls.close repo.pulls.close
@ -51,10 +82,21 @@ repo.issues.ref_pull_from
repo.issues.ref_reopening_from repo.issues.ref_reopening_from
# templates/repo/issue/view_content/comments.tmpl: ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type) # templates/repo/issue/view_content/comments.tmpl: ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type)
projects.
projects.type-1.display_name projects.type-1.display_name
projects.type-2.display_name projects.type-2.display_name
projects.type-3.display_name projects.type-3.display_name
# templates/repo/settings/webhook/link_menu.tmpl, templates/webhook/new.tmpl: repo.settings.web_hook_name_
# tests/integration/repo_archive_text_test.go
repo.settings.
# templates/shared/search/combo_multi.tmpl
search.
# templates/user/dashboard/issues.tmpl
repo.issues.filter_sort.
# modules/migration/messenger.go: invocations of Messenger # modules/migration/messenger.go: invocations of Messenger
# services/migrations/migrate.go: messenger(...) # services/migrations/migrate.go: messenger(...)
# *: repo.migrate.*.description (unknown where they come from) # *: repo.migrate.*.description (unknown where they come from)

View file

@ -43,7 +43,11 @@ func (handler Handler) handleGoTrArgument(fset *token.FileSet, n ast.Expr) {
arg, err := strconv.Unquote(argLit.Value) arg, err := strconv.Unquote(argLit.Value)
if err == nil { if err == nil {
// found interesting strings // found interesting strings
handler.OnMsgidPrefix(fset, argLit.ValuePos, arg) prep, trunc := PrepareMsgidPrefix(arg)
if trunc {
handler.OnWarning(fset, argLit.ValuePos, fmt.Sprintf("needed to truncate message id prefix: %s", arg))
}
handler.OnMsgidPrefix(fset, argLit.ValuePos, prep)
} }
} }
} }

View file

@ -273,8 +273,10 @@ func main() {
handler := Handler{ handler := Handler{
OnMsgidPrefix: func(fset *token.FileSet, pos token.Pos, msgidPrefix string) { OnMsgidPrefix: func(fset *token.FileSet, pos token.Pos, msgidPrefix string) {
// TODO: perhaps we should check if we have any strings with such a prefix, but that's slow... if !allowedMaskedPrefixes.Matches(DecodeKeyForStm(msgidPrefix)) {
allowedMaskedPrefixes.Insert(DecodeKeyForStm(msgidPrefix)) gotAnyMsgidError = true
fmt.Printf("%s:\tmissing msgid prefix: %s\n", fset.Position(pos).String(), msgidPrefix)
}
}, },
OnMsgid: func(fset *token.FileSet, pos token.Pos, msgid string) { OnMsgid: func(fset *token.FileSet, pos token.Pos, msgid string) {
if !msgids.Contains(msgid) { if !msgids.Contains(msgid) {