Warn about single-quoted translated strings

gettext only recognizes double quoted strings
This commit is contained in:
James Westman 2025-01-05 14:27:59 -06:00
parent 29e4a56bfc
commit aa13c8f5af
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
4 changed files with 21 additions and 0 deletions

View file

@ -58,6 +58,19 @@ class Translated(AstNode):
f"Cannot convert translated string to {expected_type.full_name}"
)
@validate("context")
def context_double_quoted(self):
if self.translate_context is None:
return
if not str(self.group.tokens["context"]).startswith('"'):
raise CompileWarning("gettext may not recognize single-quoted strings")
@validate("string")
def string_double_quoted(self):
if not str(self.group.tokens["string"]).startswith('"'):
raise CompileWarning("gettext may not recognize single-quoted strings")
@docs()
def ref_docs(self):
return get_docs_section("Syntax Translated")