summaryrefslogtreecommitdiff
path: root/addons/gamification
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2020-06-15 15:16:16 +0200
committerMartin Trigaux <mat@odoo.com>2020-06-18 13:03:34 +0200
commit80e97e98ce76067db1079af8feeef667cfadf837 (patch)
treee261d34e3f8458bd99011f60f508bcce2c723baf /addons/gamification
parent4a92a183e8631512a8b018eedaf9bf4956ca85e9 (diff)
[IMP] *: use named placeholders in translated message
When more than one parameter is present in a message, it helps the translation to use named placeholder. This way, the order can be changed. It also helps the comprehension of the message.
Diffstat (limited to 'addons/gamification')
-rw-r--r--addons/gamification/models/challenge.py6
-rw-r--r--addons/gamification/models/goal.py14
2 files changed, 15 insertions, 5 deletions
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 72fcf48ebad..93efdef0d9b 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -656,7 +656,11 @@ class Challenge(models.Model):
if rewarded_users:
user_names = rewarded_users.name_get()
- message_body += _("<br/>Reward (badge %s) for every succeeding user was sent to %s.") % (challenge.reward_id.name, ", ".join(name for (user_id, name) in user_names))
+ message_body += _(
+ "<br/>Reward (badge %(badge_name)s) for every succeeding user was sent to %(users)s.",
+ badge_name=challenge.reward_id.name,
+ users=", ".join(name for (user_id, name) in user_names)
+ )
else:
message_body += _("<br/>Nobody has succeeded to reach every goal, no badge is rewarded for this challenge.")
diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py
index 2236a5baa45..e26ac0b37ff 100644
--- a/addons/gamification/models/goal.py
+++ b/addons/gamification/models/goal.py
@@ -111,11 +111,17 @@ class GoalDefinition(models.Model):
Model = self.env[definition.model_id.model]
field = Model._fields.get(definition.field_id.name)
if not (field and field.store):
- raise exceptions.UserError(
- _("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not stored") % (definition.name, definition.field_id.name))
+ raise exceptions.UserError(_(
+ "The model configuration for the definition %(name)s seems incorrect, please check it.\n\n%(field_name)s not stored",
+ name=definition.name,
+ field_name=definition.field_id.name
+ ))
except KeyError as e:
- raise exceptions.UserError(
- _("The model configuration for the definition %s seems incorrect, please check it.\n\n%s not found") % (definition.name, e))
+ raise exceptions.UserError(_(
+ "The model configuration for the definition %(name)s seems incorrect, please check it.\n\n%(error)s not found",
+ name=definition.name,
+ error=e
+ ))
@api.model
def create(self, vals):