feat(build): lint-locale-usage should handle dynamically generated msgids with known prefix

This commit is contained in:
Ellen Emilia Anna Zscheile 2025-08-03 23:53:46 +02:00
commit 560eb35a85
3 changed files with 93 additions and 7 deletions

View file

@ -20,7 +20,11 @@ func (handler Handler) handleGoTrBasicLit(fset *token.FileSet, argLit *ast.Basic
if err == nil {
// found interesting strings
if strings.HasSuffix(arg, ".") || strings.HasSuffix(arg, "_") {
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)
} else {
handler.OnMsgid(fset, argLit.ValuePos, arg)
}