Use the list of supported by app translations instead of supported translations by wx
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 28 Sep 2018 13:07:46 +0300
changeset 2350 9f7028ab8294
parent 2349 645eb1bce0a5
child 2351 467f6daff4e9
Use the list of supported by app translations instead of supported translations by wx

This will make possible to translate application into locales, that
are not explicitly supported by wx: for example, 'pl' or 'bn_BD', 'bn_IN'.
i18n/mki18n.py
--- a/i18n/mki18n.py	Fri Sep 28 12:54:14 2018 +0300
+++ b/i18n/mki18n.py	Fri Sep 28 13:07:46 2018 +0300
@@ -97,9 +97,29 @@
 # -----------------------------------------------------------------------------
 
 
+def getSupportedLanguageDict(appname):
+    """
+    Returns dictionary with languages already supported
+    by given application
+
+    param: appname:
+        name of application
+    """
+    languageDict = {}
+    ext = '.po'
+    files = [x for x in os.listdir('.')
+             if x.startswith(appname) and x.endswith(ext)]
+
+    langs = [x.split(appname + '_')[1].split(ext)[0] for x in files]
+    for lang in langs:
+        languageDict[lang] = lang
+
+    return languageDict
+
+
 def getlanguageDict():
     languageDict = {}
-
+    getSupportedLanguageDict('Beremiz')
     if wx.VERSION >= (3, 0, 0):
         _app = wx.App()
     else:
@@ -205,7 +225,7 @@
     verbosePrint(verbose, cmd)
     os.system(cmd)
 
-    languageDict = getlanguageDict()
+    languageDict = getSupportedLanguageDict(applicationName)
 
     for langCode in languageDict.keys():
         if langCode == 'en':
@@ -230,7 +250,7 @@
     currentDir = os.getcwd()
     os.chdir(applicationDirectoryPath)
 
-    languageDict = getlanguageDict()
+    languageDict = getSupportedLanguageDict(applicationName)
 
     for langCode in languageDict.keys():
         if langCode == 'en':
@@ -284,7 +304,7 @@
     currentDir = os.getcwd()
     os.chdir(applicationDirectoryPath)
 
-    languageDict = getlanguageDict()
+    languageDict = getSupportedLanguageDict(applicationName)
 
     for langCode in languageDict.keys():
         if (langCode == 'en') and (forceEnglish == 0):