Adding support for disable language translation when default language not available in locale
authorlaurent
Thu, 31 Mar 2011 12:09:52 +0200
changeset 513 fb787f6cbe33
parent 512 07a7989f58e4
child 514 ee435a8546b9
Adding support for disable language translation when default language not available in locale
PLCOpenEditor.py
--- a/PLCOpenEditor.py	Thu Mar 31 10:53:13 2011 +0200
+++ b/PLCOpenEditor.py	Thu Mar 31 12:09:52 2011 +0200
@@ -83,14 +83,19 @@
 # Get folder containing translation files
 localedir = os.path.join(CWD,"locale")
 # Get the default language
-langid = wx.LANGUAGE_DEFAULT
+langid = wx.LANGUAGE_SPANISH#wx.LANGUAGE_DEFAULT
 # Define translation domain (name of translation files)
 domain = "PLCOpenEditor"
 
 # Define locale for wx
 loc = __builtin__.__dict__.get('loc', None)
 if loc is None:
-    loc = wx.Locale(langid)
+    test_loc = wx.Locale(langid)
+    test_loc.AddCatalogLookupPathPrefix(localedir)
+    if test_loc.AddCatalog(domain):
+        loc = wx.Locale(langid)
+    else:
+        loc = wx.Locale(wx.LANGUAGE_ENGLISH)
     __builtin__.__dict__['loc'] = loc
 # Define location for searching translation files
 loc.AddCatalogLookupPathPrefix(localedir)