values: Don't allow translated strings in arrays

Gtk.Builder has no way to translate individual strings in a string
array, so don't allow it in the syntax.
This commit is contained in:
James Westman 2025-01-03 18:56:24 -06:00
parent f3faf4b993
commit 55e5095fba
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
3 changed files with 16 additions and 0 deletions

View file

@ -452,6 +452,14 @@ class ArrayValue(AstNode):
range=quoted_literal.range,
)
)
elif isinstance(value.child, Translated):
errors.append(
CompileError(
"Arrays can't contain translated strings",
range=value.child.range,
)
)
if len(errors) > 0:
raise MultipleErrors(errors)

View file

@ -0,0 +1,7 @@
using Gtk 4.0;
StringList {
strings: [
_("Test")
];
}

View file

@ -0,0 +1 @@
5,5,9,Arrays can't contain translated strings