Skip to content

Commit

Permalink
chore: fix error translations
Browse files Browse the repository at this point in the history
* lazy_gettext uses the %(variable)s formatting to insert variables into
  the translated text
* with f-strings, we would be inserting the variables before the
  translation happens
  • Loading branch information
max-moser authored and zzacharo committed Sep 11, 2023
1 parent 0e7f2d6 commit 59a4f94
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions invenio_rdm_records/services/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ def __init__(self, record_id):
def description(self):
"""Exception's description."""
return _(
"Embargo could not be lifted for record: {record_id}".format(
record_id=self.record_id
)
"Embargo could not be lifted for record: %(record_id)s",
record_id=self.record_id,
)


Expand Down Expand Up @@ -154,9 +153,9 @@ def __init__(self, record_id, community_id):
def description(self):
"""Exception description."""
return _(
"The record {record_id} in not included in the community {community_id}.".format(
record_id=self.record_id, community_id=self.community_id
)
"The record %(rec_id)s in not included in the community %(com_id)s.",
rec_id=self.record_id,
com_id=self.community_id,
)


Expand All @@ -170,7 +169,7 @@ def __init__(self, reason):
@property
def description(self):
"""Exception description."""
return _("Cannot modify community visibility: {reason}".format(self.reason))
return _("Cannot modify community visibility: %(reason)s", reason=self.reason)


class AccessRequestException(RDMRecordsException):
Expand All @@ -188,6 +187,9 @@ def __init__(self, request_id):
def description(self):
"""Exception description."""
if self.request_id:
return _(f"Identical access requests already exist: {self.request_id}")
return _(
"Identical access requests already exist: %(request_id)s",
request_id=self.request_id,
)
else:
return _("The access request is a duplicate")

0 comments on commit 59a4f94

Please sign in to comment.