add '_' function to builtin dictionary at import time
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 15 Sep 2017 18:57:20 +0300
changeset 1806 6b4d0f4f2fbc
parent 1805 52daabbb6f90
child 1807 5562f34f2fc2
add '_' function to builtin dictionary at import time

This allows to import many Beremiz python modules before calling
util.misc.InstallLocalRessources().
util/TranslationCatalogs.py
util/misc.py
--- a/util/TranslationCatalogs.py	Fri Sep 15 18:51:42 2017 +0300
+++ b/util/TranslationCatalogs.py	Fri Sep 15 18:57:20 2017 +0300
@@ -23,7 +23,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 import os
-
+import __builtin__
 import wx
 
 # Get the default language
@@ -33,6 +33,9 @@
 locale = wx.Locale(langid)
 
 
+__builtin__.__dict__['_'] = wx.GetTranslation
+
+
 def GetDomain(path):
     for name in os.listdir(path):
         filepath = os.path.join(path, name)
--- a/util/misc.py	Fri Sep 15 18:51:42 2017 +0300
+++ b/util/misc.py	Fri Sep 15 18:57:20 2017 +0300
@@ -64,6 +64,3 @@
     # Internationalization
     AddCatalog(os.path.join(CWD, "locale"))
     import gettext
-    import __builtin__
-
-    __builtin__.__dict__['_'] = wx.GetTranslation