translation-not-lazy (W8301)#

A string is formatted with % or + before it is translated.

Applies to Odoo 14.0 and later.

What it does#

Reports _("..." % value), _("..." + value) and _("...") % value.

Why is this bad?#

_() looks up the exact string in the translation catalogue. Once the value is formatted in, the string is never found and stays untranslated. Pass the values as arguments instead, so _() formats after translating.

Example#

raise UserError(_("Order %s is locked") % order.name)

Use instead:

raise UserError(_("Order %s is locked", order.name))

Ruff’s INT003 (flake8-gettext) is similar, for _() only.