# HG changeset patch # User Andrey Skvortsov # Date 1538129266 -10800 # Node ID 9f7028ab8294e6a87bb572b1fe7ded2e52310678 # Parent 645eb1bce0a5ddd0e31074e97c4614057c16104b 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'. diff -r 645eb1bce0a5 -r 9f7028ab8294 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):