Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add W304 for untranslated messages #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 29 additions & 1 deletion dennis/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,32 @@ def tokenize(text):
return msgs


class EmptyLintRule(LintRule):
num = "W304"
name = "empty"
desc = "Untranslated string"

def lint(self, vartok, linted_entry):
msgs = []

for trstr in linted_entry.strs:
if trstr.msgstr_string:
continue

msgs.append(
LintMessage(
WARNING,
linted_entry.poentry.linenum,
0,
self.num,
"String is untranslated",
linted_entry.poentry,
)
)

return msgs


class InvalidVarsLintRule(LintRule):
num = "E201"
name = "invalidvars"
Expand Down Expand Up @@ -580,7 +606,9 @@ def verify_file(self, filename_or_string):
"""
po = parse_pofile(filename_or_string)
msgs = []
for entry in po.translated_entries():
for entry in po:
if entry.fuzzy or entry.obsolete:
continue
msgs.extend(self.lint_poentry(entry))

return msgs