Skip to content

translation-contains-variable (ODOO041)

Preview (since 0.16.2.2) · 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 already has variables interpolated into it, e.g. _("Hello %s" % name) or _("Hello {}".format(name)).

Why is this bad?

The interpolation happens before translation, so the looked-up term contains the runtime value and never matches the exported translation entry.

Example

_("Hello %s" % name)

Use instead:

_("Hello %s") % name