Skip to content

translation-format-truncated (ODOO057)

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 terms ending in the middle of a printf conversion specifier, e.g. _("Hello %", name).

Why is this bad?

The translation function formats the term with %, so a truncated conversion specifier raises a ValueError at runtime.

Example

_("Progress: 100 %", progress)

Use instead:

_("Progress: %s %%", progress)