chiark / gitweb /
Add missing , to last patch
[cura.git] / Cura / util / resources.py
index 473f496459e09e1ea212a23261164e00bbf7bcd9..7b7c48c9d8c391781c90244356443a6bad999090 100644 (file)
@@ -4,6 +4,7 @@ __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AG
 import os
 import sys
 
+#Cura/util classes should not depend on wx...
 import wx
 import gettext
 
@@ -43,15 +44,31 @@ def getPathForMesh(name):
 def getPathForFirmware(name):
        return getPathForResource(resourceBasePath, 'firmware', name)
 
-def setupLocalization():
+def setupLocalization(selectedLanguage = None):
        try:
                if sys.platform.startswith('darwin'):
                        languages = NSLocale.preferredLanguages()
                else:
+                       #Using wx.Locale before you created wx.App seems to cause an nasty exception. So default to 'en' at the moment.
                        languages = [wx.Locale(wx.LANGUAGE_DEFAULT).GetCanonicalName()]
        except Exception as e:
                languages = ['en']
 
+       if selectedLanguage is not None:
+               for item in getLanguageOptions():
+                       if item[1] == selectedLanguage:
+                               languages = [item[0]] + languages
+
        locale_path = os.path.normpath(os.path.join(resourceBasePath, 'locale'))
        translation = gettext.translation('Cura', locale_path, languages, fallback=True)
        translation.install(unicode=True)
+
+def getLanguageOptions():
+       return [
+               ['en', 'English'],
+               ['de', 'Deutsch'],
+               ['fr', 'French'],
+               ['nl', 'Nederlands'],
+               ['sp', 'Spanish'],
+               ['po', 'Polish']
+       ]