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

@tr is not recognized in syntax #65

Open
kroltan opened this issue Nov 16, 2024 · 2 comments
Open

@tr is not recognized in syntax #65

kroltan opened this issue Nov 16, 2024 · 2 comments

Comments

@kroltan
Copy link

kroltan commented Nov 16, 2024

  • Plugin version 1.2.0
  • RustRover 2024.2.1
  • Slint 1.7.2

The @tr("Some text") syntax is not recognised, issuing errors in the code analysis panel. The actual markup seems to survive mostly fine, but the property that uses that directive is not highlighted with the usual color.

Text {
    font-weight: Style.bold-weight;
    text: @tr("Settings");
}

2024-11-16_14-05

The error tooltip reads:

<expression> or '=' expected, got '@'


While I only reported this now, it's been happening for the couple months I've been using this plugin (which is awesome! thank you for your work), so it's not related to the Slint 1.8 release.

@kizeevov
Copy link
Owner

Fixed in version 1.3.0. Please check.
Thanks for the feedback!

@kroltan
Copy link
Author

kroltan commented Nov 29, 2024

Thank you! It's mostly working, but looks like there's still some cases it's not recognising syntax that Slint itself accepts:

ready-text: up-to-date
    ? @tr("Up-to-date: {}", current-version)
    : humanized-ready-size;

Reports 2 errors:

  • <builtin functions>, <expression> or '=' expected, got 'up-to-date' in the space after the colon and the start of the condition expression;
  • invalid expression in the colon of the else-clause.

If I erase the current-version parameter, I get a different error Format string contains 1 placeholders, but only 0 extra arguments were given at the @, and if I then erase the curly braces so it looks like @tr("Up-to-date") there is no error.

If the @tr is in the else-clause, then there is no error.


Also I just noticed a similar inconsistency in available syntax with the @linear-gradient builtin:

background: @linear-gradient(
    0,
    gradient-steps()[0] 50%,
    gradient-steps()[1] 70%
);

If I use the indexing expression like that, I get the error 'linear-gradient' unexpected just after the @ sign.

If I use a simpler expression like gradient-from() for the color field, then it accepts the syntax. This is not a problem for me since I didn't like the array solution very much anyways, but might hint there's something more generally funny going on.


If it helps you debug, the code I'm looking at is open-source. (The linear-gradient thing is on the ./button.slint file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants