Skip to content

Commit b8a88c4

Browse files
committed
fix(i18n): fix incorrect lookup of some translations
The code had: _("some term %s here" % term) this extracts the template, but looks up the string with %s replaced. So the translation is broken. Changed to: _("some term %s here") % term which looks up the template and substitutes in the translation of the template. Found by ruff INT ruleset.
1 parent 81b56d5 commit b8a88c4

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

roundup/backends/back_anydbm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def __getattr__(self, classname):
212212
def addclass(self, cl):
213213
cn = cl.classname
214214
if cn in self.classes:
215-
raise ValueError(_('Class "%s" already defined.' % cn))
215+
raise ValueError(_('Class "%s" already defined.') % cn)
216216
self.classes[cn] = cl
217217

218218
# add default Edit and View permissions

roundup/backends/rdbms_common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ def update_class(self, spec, old_spec, force=0):
629629

630630
if not self.config.RDBMS_ALLOW_ALTER:
631631
raise DatabaseError(_(
632-
'ALTER operation disallowed: %(old)r -> %(new)r.' % {
633-
'old': old_spec, 'new': new_spec}))
632+
'ALTER operation disallowed: %(old)r -> %(new)r.') % {
633+
'old': old_spec, 'new': new_spec})
634634

635635
logger = logging.getLogger('roundup.hyperdb.backend')
636636
logger.info('update_class %s' % spec.classname)
@@ -864,8 +864,8 @@ def create_class(self, spec):
864864
"""
865865

866866
if not self.config.RDBMS_ALLOW_CREATE:
867-
raise DatabaseError(_('CREATE operation disallowed: "%s".' %
868-
spec.classname))
867+
raise DatabaseError(_('CREATE operation disallowed: "%s".') %
868+
spec.classname)
869869

870870
cols, mls = self.create_class_table(spec)
871871
self.create_journal_table(spec)
@@ -881,7 +881,7 @@ def drop_class(self, cn, spec):
881881
"""
882882

883883
if not self.config.RDBMS_ALLOW_DROP:
884-
raise DatabaseError(_('DROP operation disallowed: "%s".' % cn))
884+
raise DatabaseError(_('DROP operation disallowed: "%s".') % cn)
885885

886886
properties = spec[1]
887887
# figure the multilinks
@@ -925,7 +925,7 @@ def addclass(self, cl):
925925
"""
926926
cn = cl.classname
927927
if cn in self.classes:
928-
raise ValueError(_('Class "%s" already defined.' % cn))
928+
raise ValueError(_('Class "%s" already defined.') % cn)
929929
self.classes[cn] = cl
930930

931931
# add default Edit and View permissions

roundup/backends/sessions_redis.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def get(self, infoid, value, default=_marker):
7676
if default != self._marker:
7777
return default
7878
raise KeyError(_('Key %(key)s not found in %(name)s '
79-
'database.' % {"name": self.name,
80-
"key": escape(infoid)}))
79+
'database.') % {"name": self.name,
80+
"key": escape(infoid)})
8181
return self.todict(v)[value]
8282

8383
def getall(self, infoid):
@@ -95,8 +95,8 @@ def getall(self, infoid):
9595
# If so, we get a misleading error, but anydbm does the
9696
# same so....
9797
raise KeyError(_('Key %(key)s not found in %(name)s '
98-
'database.' % {"name": self.name,
99-
"key": escape(infoid)}))
98+
'database.') % {"name": self.name,
99+
"key": escape(infoid)})
100100

101101
''' def set_no_tranaction(self, infoid, **newvalues):
102102
""" this is missing transaction and may be affected by
@@ -190,8 +190,8 @@ def set(self, infoid, **newvalues):
190190
break
191191
except redis.exceptions.WatchError:
192192
self.log_info(
193-
_('Key %(key)s changed in %(name)s db' %
194-
{"key": escape(infoid), "name": self.name})
193+
_('Key %(key)s changed in %(name)s db') %
194+
{"key": escape(infoid), "name": self.name}
195195
)
196196
else:
197197
try:

roundup/cgi/timestamp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def timecheck(self, field, delay):
2929
try:
3030
created = unpack_timestamp(self.form[field].value)
3131
except KeyError:
32-
raise FormError(_("Form is corrupted, missing: %s." % field))
32+
raise FormError(_("Form is corrupted, missing: %s.") % field)
3333
if time.time() - created < delay:
3434
raise FormError(_("Responding to form too quickly."))
3535
return True

roundup/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ def get_attribute(self, class_name, item_id, attr_name, input):
11101110
try:
11111111
data = node.__getattr__(attr_name)
11121112
except AttributeError:
1113-
raise UsageError(_("Invalid attribute %s" % attr_name))
1113+
raise UsageError(_("Invalid attribute %s") % attr_name)
11141114
result = {
11151115
'id': item_id,
11161116
'type': str(type(data)),

roundup/roundupdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def confirm_registration(self, otk):
137137
# Try to make error message less cryptic to the user.
138138
if str(e) == 'node with key "%s" exists' % username:
139139
raise ValueError(
140-
_("Username '%s' already exists." % username))
140+
_("Username '%s' already exists.") % username)
141141
else:
142142
raise
143143

roundup/scripts/roundup_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ def start_response(self, headers, response):
548548

549549
def error():
550550
exc_type, exc_value = sys.exc_info()[:2]
551-
return _('Error: %(type)s: %(value)s' % {'type': exc_type,
552-
'value': exc_value})
551+
return _('Error: %(type)s: %(value)s') % {'type': exc_type,
552+
'value': exc_value}
553553

554554

555555
def setgid(group):
@@ -840,11 +840,11 @@ class ThreadingServer(socketserver.ThreadingMixIn,
840840
raise socket.error(_(
841841
"Unable to bind to port %(port)s, "
842842
"access not allowed, "
843-
"errno: %(errno)s %(msg)s" % {
843+
"errno: %(errno)s %(msg)s") % {
844844
"port": self["PORT"],
845845
"errno": e.args[0],
846846
"msg": e.args[1]}
847-
))
847+
)
848848

849849
raise
850850
# change user and/or group

0 commit comments

Comments
 (0)