mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Warn about single-quoted translated strings
gettext only recognizes double quoted strings
This commit is contained in:
parent
29e4a56bfc
commit
aa13c8f5af
4 changed files with 21 additions and 0 deletions
|
@ -58,6 +58,19 @@ class Translated(AstNode):
|
||||||
f"Cannot convert translated string to {expected_type.full_name}"
|
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()
|
@docs()
|
||||||
def ref_docs(self):
|
def ref_docs(self):
|
||||||
return get_docs_section("Syntax Translated")
|
return get_docs_section("Syntax Translated")
|
||||||
|
|
|
@ -24,6 +24,8 @@ If you're using Meson's `i18n module <https://mesonbuild.com/i18n-module.html#i1
|
||||||
|
|
||||||
i18n.gettext('package name', preset: 'glib')
|
i18n.gettext('package name', preset: 'glib')
|
||||||
|
|
||||||
|
You must use double quotes for the translated strings in order for gettext to recognize them. Newer versions of blueprint will warn you if you use single quotes.
|
||||||
|
|
||||||
Contexts
|
Contexts
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
5
tests/sample_errors/single_quoted_translated.blp
Normal file
5
tests/sample_errors/single_quoted_translated.blp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
using Gtk 4.0;
|
||||||
|
|
||||||
|
Label {
|
||||||
|
label: _('Hello, World!');
|
||||||
|
}
|
1
tests/sample_errors/single_quoted_translated.err
Normal file
1
tests/sample_errors/single_quoted_translated.err
Normal file
|
@ -0,0 +1 @@
|
||||||
|
4,12,15,gettext may not recognize single-quoted strings
|
Loading…
Add table
Add a link
Reference in a new issue