translation-fstring-interpolation (ODOO058)
Preview (since 0.16.2.9) · Related issues · View source
Derived from the odoo linter.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for translation calls whose term is an f-string, e.g. _(f"Hello {name}").
Why is this bad?
An f-string interpolates its values before the translation call runs, so the
looked-up term contains the runtime values and never matches the exported
translation entry. Since Odoo 14.0 the translation functions (_, self.env._)
interpolate the values themselves: _("Hello %s", name).
Example
Use instead: