lazy locale initialization
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 15 Sep 2017 20:28:54 +0300
changeset 1813 c18adf359d21
parent 1812 8626a4948d5e
child 1814 fc387c4fc1d4
lazy locale initialization

wx.Locale() can't be called without wx.App. So don't call it at
import. It makes PLCOpenEditor simpler.
util/TranslationCatalogs.py
--- a/util/TranslationCatalogs.py	Fri Sep 15 20:05:41 2017 +0300
+++ b/util/TranslationCatalogs.py	Fri Sep 15 20:28:54 2017 +0300
@@ -26,11 +26,7 @@
 import __builtin__
 import wx
 
-# Get the default language
-langid = wx.LANGUAGE_DEFAULT
-
-# Define locale for wx
-locale = wx.Locale(langid)
+locale = None
 
 
 __builtin__.__dict__['_'] = wx.GetTranslation
@@ -53,6 +49,11 @@
     if os.path.exists(locale_dir) and os.path.isdir(locale_dir):
         domain = GetDomain(locale_dir)
         if domain is not None:
+            global locale
+            if locale is None:
+                # Define locale for wx
+                locale = wx.Locale(wx.LANGUAGE_DEFAULT)
+
             locale.AddCatalogLookupPathPrefix(locale_dir)
             locale.AddCatalog(domain)