changeset 7750:216662fbaaee

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.
author John Rouillard <rouilj@ieee.org>
date Fri, 01 Mar 2024 14:04:05 -0500
parents 79344ea780ea
children bd013590d8d6
files roundup/backends/back_anydbm.py roundup/backends/rdbms_common.py roundup/backends/sessions_redis.py roundup/cgi/timestamp.py roundup/rest.py roundup/roundupdb.py roundup/scripts/roundup_server.py
diffstat 7 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/backends/back_anydbm.py	Fri Mar 01 14:04:05 2024 -0500
@@ -212,7 +212,7 @@
     def addclass(self, cl):
         cn = cl.classname
         if cn in self.classes:
-            raise ValueError(_('Class "%s" already defined.' % cn))
+            raise ValueError(_('Class "%s" already defined.') % cn)
         self.classes[cn] = cl
 
         # add default Edit and View permissions
--- a/roundup/backends/rdbms_common.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/backends/rdbms_common.py	Fri Mar 01 14:04:05 2024 -0500
@@ -629,8 +629,8 @@
 
         if not self.config.RDBMS_ALLOW_ALTER:
             raise DatabaseError(_(
-                'ALTER operation disallowed: %(old)r -> %(new)r.' % {
-                    'old': old_spec, 'new': new_spec}))
+                'ALTER operation disallowed: %(old)r -> %(new)r.') % {
+                    'old': old_spec, 'new': new_spec})
 
         logger = logging.getLogger('roundup.hyperdb.backend')
         logger.info('update_class %s' % spec.classname)
@@ -864,8 +864,8 @@
         """
 
         if not self.config.RDBMS_ALLOW_CREATE:
-            raise DatabaseError(_('CREATE operation disallowed: "%s".' %
-                                  spec.classname))
+            raise DatabaseError(_('CREATE operation disallowed: "%s".') %
+                                  spec.classname)
 
         cols, mls = self.create_class_table(spec)
         self.create_journal_table(spec)
@@ -881,7 +881,7 @@
         """
 
         if not self.config.RDBMS_ALLOW_DROP:
-            raise DatabaseError(_('DROP operation disallowed: "%s".' % cn))
+            raise DatabaseError(_('DROP operation disallowed: "%s".') % cn)
 
         properties = spec[1]
         # figure the multilinks
@@ -925,7 +925,7 @@
         """
         cn = cl.classname
         if cn in self.classes:
-            raise ValueError(_('Class "%s" already defined.' % cn))
+            raise ValueError(_('Class "%s" already defined.') % cn)
         self.classes[cn] = cl
 
         # add default Edit and View permissions
--- a/roundup/backends/sessions_redis.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/backends/sessions_redis.py	Fri Mar 01 14:04:05 2024 -0500
@@ -76,8 +76,8 @@
             if default != self._marker:
                 return default
             raise KeyError(_('Key %(key)s not found in %(name)s '
-                             'database.' % {"name": self.name,
-                                            "key": escape(infoid)}))
+                             'database.') % {"name": self.name,
+                                            "key": escape(infoid)})
         return self.todict(v)[value]
 
     def getall(self, infoid):
@@ -95,8 +95,8 @@
             # If so, we get a misleading error, but anydbm does the
             # same so....
             raise KeyError(_('Key %(key)s not found in %(name)s '
-                             'database.' % {"name": self.name,
-                                            "key": escape(infoid)}))
+                             'database.') % {"name": self.name,
+                                            "key": escape(infoid)})
 
         ''' def set_no_tranaction(self, infoid, **newvalues):
         """ this is missing transaction and may be affected by
@@ -190,8 +190,8 @@
                     break
                 except redis.exceptions.WatchError:
                     self.log_info(
-                        _('Key %(key)s changed in %(name)s db' %
-                          {"key": escape(infoid), "name": self.name})
+                        _('Key %(key)s changed in %(name)s db') %
+                          {"key": escape(infoid), "name": self.name}
                     )
             else:
                 try:
--- a/roundup/cgi/timestamp.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/cgi/timestamp.py	Fri Mar 01 14:04:05 2024 -0500
@@ -29,7 +29,7 @@
         try:
             created = unpack_timestamp(self.form[field].value)
         except KeyError:
-            raise FormError(_("Form is corrupted, missing: %s." % field))
+            raise FormError(_("Form is corrupted, missing: %s.") % field)
         if time.time() - created < delay:
             raise FormError(_("Responding to form too quickly."))
         return True
--- a/roundup/rest.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/rest.py	Fri Mar 01 14:04:05 2024 -0500
@@ -1110,7 +1110,7 @@
         try:
             data = node.__getattr__(attr_name)
         except AttributeError:
-            raise UsageError(_("Invalid attribute %s" % attr_name))
+            raise UsageError(_("Invalid attribute %s") % attr_name)
         result = {
             'id': item_id,
             'type': str(type(data)),
--- a/roundup/roundupdb.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/roundupdb.py	Fri Mar 01 14:04:05 2024 -0500
@@ -137,7 +137,7 @@
             # Try to make error message less cryptic to the user.
             if str(e) == 'node with key "%s" exists' % username:
                 raise ValueError(
-                    _("Username '%s' already exists." % username))
+                    _("Username '%s' already exists.") % username)
             else:
                 raise
 
--- a/roundup/scripts/roundup_server.py	Wed Feb 28 22:40:32 2024 -0500
+++ b/roundup/scripts/roundup_server.py	Fri Mar 01 14:04:05 2024 -0500
@@ -548,8 +548,8 @@
 
 def error():
     exc_type, exc_value = sys.exc_info()[:2]
-    return _('Error: %(type)s: %(value)s' % {'type': exc_type,
-                                             'value': exc_value})
+    return _('Error: %(type)s: %(value)s') % {'type': exc_type,
+                                             'value': exc_value}
 
 
 def setgid(group):
@@ -840,11 +840,11 @@
                 raise socket.error(_(
                     "Unable to bind to port %(port)s, "
                     "access not allowed, "
-                    "errno: %(errno)s %(msg)s" % {
+                    "errno: %(errno)s %(msg)s") % {
                         "port": self["PORT"],
                         "errno": e.args[0],
                         "msg": e.args[1]}
-                ))
+                )
 
             raise
         # change user and/or group

Roundup Issue Tracker: http://roundup-tracker.org/