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

[IMP] compiler: add support for the .translate suffix #1613

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

sdegueldre
Copy link
Contributor

@sdegueldre sdegueldre commented May 13, 2024

Previously, if you wanted to pass a prop and have it be translated, you had to either to the translation manually in JS, or use a workaround with t-set and a body so that Owl would translate it for you, and then pass the t-set variable as a prop. This is quite inconvenient and is a common use case.

This commit introduces the .translate suffix to solve this issue. When a prop uses this suffix, it is treated as a string instead of a JS expression, avoiding the need for quotes as well as their escaping and allowing extraction tools such as babel to generate a clean string as the term's translation id. This is also more ergonomic.

This change will still require some work in Odoo to correctly extract the terms for props using this suffix.

Odoo PR adding extraction for the suffix: odoo/odoo#165922

@sdegueldre sdegueldre force-pushed the master-add-translate-suffix-sad branch 3 times, most recently from b43529f to 1afc804 Compare May 17, 2024 08:48
@sdegueldre sdegueldre force-pushed the master-add-translate-suffix-sad branch 2 times, most recently from a0f3b11 to d748479 Compare May 17, 2024 09:21
Previously, if you wanted to pass a prop and have it be translated, you
had to either to the translation manually in JS, or use a workaround
with t-set and a body so that Owl would translate it for you, and then
pass the t-set variable as a prop. This is quite inconvenient and is a
common use case.

This commit introduces the `.translate` suffix to solve this issue. When
a prop uses this suffix, it is treated as a string instead of a JS
expression, avoiding the need for quotes as well as their escaping and
allowing extraction tools such as babel to generate a clean string as
the term's translation id. This is also more ergonomic. This suffix is
available for both component props and slot props.

This change will still require some work in Odoo to correctly extract
the terms for props using this suffix.
@sdegueldre sdegueldre force-pushed the master-add-translate-suffix-sad branch from d748479 to 515651d Compare May 17, 2024 09:24
@ged-odoo ged-odoo merged commit 0cde4b8 into master Jul 15, 2024
3 checks passed
@ged-odoo ged-odoo deleted the master-add-translate-suffix-sad branch July 15, 2024 08:14
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

Successfully merging this pull request may close these issues.

2 participants