diff roundup/admin.py @ 6658:408fd477761f

Add i18n object to roundupdb.Database This makes the i18n object accessible everywhere (including in detectors where localized error messages were impossible). See issue2551184
author Ralf Schlatterbeck <rsc@runtux.com>
date Tue, 03 May 2022 14:51:59 +0200
parents d4371b131c9c
children 00fe67eb8a91
line wrap: on
line diff
--- a/roundup/admin.py	Mon May 02 17:04:27 2022 -0400
+++ b/roundup/admin.py	Tue May 03 14:51:59 2022 +0200
@@ -30,7 +30,7 @@
 import roundup.instance
 from roundup.configuration import (CoreConfig, NoConfigError,
                                    ParsingOptionError, UserConfig)
-from roundup.i18n import _
+from roundup.i18n import _, get_translation
 from roundup.exceptions import UsageError
 from roundup.anypy.my_input import my_input
 from roundup.anypy.strings import repr_export
@@ -1719,6 +1719,11 @@
         # only open the database once!
         if not self.db:
             self.db = tracker.open(self.name)
+            # dont use tracker.config["TRACKER_LANGUAGE"] here as the
+            # cli operator likely wants to have i18n as set in the
+            # environment.
+            # This is needed to fetch the locale's of the tracker's home dir.
+            self.db.i18n = get_translation (tracker_home = tracker.tracker_home)
 
         self.db.tx_Source = 'cli'
 

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