slint icon indicating copy to clipboard operation
slint copied to clipboard

compiler: Accept additional comparison syntax for plural forms in bun…

Open tronical opened this issue 1 month ago • 4 comments

…dled translations

Tolgee produces these plural forms and they cause the compiler to panic.

Upstream PR: https://github.com/tolgee/tolgee-platform/pull/3346

tronical avatar Dec 12 '25 08:12 tronical

I believe gettext doesn't understand these either and that toglee is producing invalid expressions.

But this patch can't hurt anyway.

I'm just curious where it panics?

ogoffart avatar Dec 12 '25 09:12 ogoffart

This is the panic:

thread 'translations::plural_rule_parser::test_parse_rule_expression' (33972856) panicked at internal/compiler/translations.rs:465:20:
parse error: ParseError(unexpected token, rest="= 1)")

The comparison operator code tries to strip, so with for example === it will strip the == and then expect the next bit (=) to be an operand. That's not going to work :)

tronical avatar Dec 12 '25 09:12 tronical

I believe gettext doesn't understand these either and that toglee is producing invalid expressions.

I agree. I've sent them an email.

tronical avatar Dec 12 '25 09:12 tronical

I proposed a fix upstream.

tronical avatar Dec 12 '25 09:12 tronical

This is the panic:

thread 'translations::plural_rule_parser::test_parse_rule_expression' (33972856) panicked at internal/compiler/translations.rs:465:20:
parse error: ParseError(unexpected token, rest="= 1)")

Ah but that's the test. I thought the compiler was panicking when running. But ideally, I hope it shows an error.

ogoffart avatar Dec 12 '25 12:12 ogoffart

Ah but that's the test. I thought the compiler was panicking when running.

Right, the compiler doesn't panic. The app's build process aborted in build.rs because of the error.

tronical avatar Dec 12 '25 12:12 tronical