diff --git a/invesalius/gui/language_dialog.py b/invesalius/gui/language_dialog.py index ae6eddd..5ab7758 100644 --- a/invesalius/gui/language_dialog.py +++ b/invesalius/gui/language_dialog.py @@ -39,38 +39,30 @@ class LanguageDialog(wx.Dialog): def __init_combobox_bitmap__(self): """Initialize combobox bitmap""" - - self.locales = i18n.GetLocales().values() - self.locales_key = i18n.GetLocales().keys() + + dict_locales = i18n.GetLocales() + + self.locales = dict_locales.values() + self.locales.sort() + + print "-------------------" + print self.locales + self.locales_key = [dict_locales.get_key(value)[0] for value in self.locales] + print self.locales_key self.os_locale = i18n.GetLocaleOS() - + + os_lang = self.os_locale[0:2] + selection = self.locales_key.index('en') + self.bitmapCmb = bitmapCmb = wx.combo.BitmapComboBox(self, style=wx.CB_READONLY) + for key in self.locales_key: + filepath = os.path.join(ICON_DIR, "%s.bmp"%(key)) + bmp = wx.Bitmap(filepath, wx.BITMAP_TYPE_BMP) + bitmapCmb.Append(dict_locales[key], bmp, key) + if key.startswith(os_lang): + selection = self.locales_key.index(key) + bitmapCmb.SetSelection(selection) - bmp_french_flag = wx.Bitmap(os.path.join(ICON_DIR, "fr_FR.bmp"), wx.BITMAP_TYPE_BMP) - bmp_english_flag = wx.Bitmap(os.path.join(ICON_DIR, "en_GB.bmp"), wx.BITMAP_TYPE_BMP) - bmp_brazilian_flag = wx.Bitmap(os.path.join(ICON_DIR, "pt_BR.bmp"), wx.BITMAP_TYPE_BMP) - bmp_spanish_flag = wx.Bitmap(os.path.join(ICON_DIR, "es.bmp"), wx.BITMAP_TYPE_BMP) - bmp_greek_flag = wx.Bitmap(os.path.join(ICON_DIR, "el_GR.bmp"), wx.BITMAP_TYPE_BMP) - - bitmapCmb.Append(self.locales[0], bmp_greek_flag, "el_GR") - bitmapCmb.Append(self.locales[1], bmp_french_flag,"fr") - bitmapCmb.Append(self.locales[2], bmp_english_flag,"en_GB") - bitmapCmb.Append(self.locales[3], bmp_brazilian_flag,"pt_BR") - bitmapCmb.Append(self.locales[4], bmp_spanish_flag,"es") - - - - os_lang = self.os_locale[0:2] - if (os_lang == 'pt'): - bitmapCmb.SetSelection(3) - elif (os_lang == 'es'): - bitmapCmb.SetSelection(4) - elif (os_lang == 'fr'): - bitmapCmb.SetSelection(1) - elif (os_lang == 'el'): - bitmapCmb.SetSelection(0) - else: - bitmapCmb.SetSelection(2) def __init_gui(self): self.txtMsg = wx.StaticText(self, -1, diff --git a/invesalius/i18n.py b/invesalius/i18n.py index f3a1c04..7c13dc2 100644 --- a/invesalius/i18n.py +++ b/invesalius/i18n.py @@ -26,16 +26,20 @@ import gettext import os import sys +import utils as utl + LANGUAGE_DIR = os.path.abspath(os.path.join('..','locale')) def GetLocales(): """Return a dictionary which defines supported languages""" - locale_descriptions = {'en': u'English', - 'es': u'Español', - 'pt_BR': u'Português (Brasil)', - 'fr':u'Français', - 'el_GR':u'Ελληνική'} - return locale_descriptions + d = utl.TwoWaysDictionary ({'en': u'English', + 'es': u'Español', + 'pt_BR': u'Português (Brasil)', + 'fr':u'Français', + 'el_GR':u'Ελληνική', + 'it_IT':'Italiano', + 'de_DE': 'Deutsch'}) + return d def GetLocaleOS(): """Return language of the operating system.""" diff --git a/invesalius/invesalius.py b/invesalius/invesalius.py index cf62e1c..d8617b7 100755 --- a/invesalius/invesalius.py +++ b/invesalius/invesalius.py @@ -46,7 +46,7 @@ import wx.lib.pubsub as ps class SplashScreen(wx.SplashScreen): def __init__(self): - + lang = False save_session = False session = Session() if not (session.ReadSession()): @@ -74,29 +74,30 @@ class SplashScreen(wx.SplashScreen): session.SetLanguage(lang) session.CreateSessionFile() - if (lang.startswith('pt')): #Necessy, pt noted as pt_BR - icon_file = "splash_pt.png" - else: - icon_file = "splash_" + lang + ".png" + if lang: + if (lang.startswith('pt')): #Necessy, pt noted as pt_BR + icon_file = "splash_pt.png" + else: + icon_file = "splash_" + lang + ".png" - path = os.path.join("..","icons", icon_file) + path = os.path.join("..","icons", icon_file) - bmp = wx.Image(path).ConvertToBitmap() + bmp = wx.Image(path).ConvertToBitmap() - wx.SplashScreen.__init__(self, bitmap=bmp, + wx.SplashScreen.__init__(self, bitmap=bmp, splashStyle=wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, milliseconds=1500, id=-1, parent=None) - self.Bind(wx.EVT_CLOSE, self.OnClose) + self.Bind(wx.EVT_CLOSE, self.OnClose) - from gui.frame import Frame - from control import Controller - from project import Project + from gui.frame import Frame + from control import Controller + from project import Project - self.main = Frame(None) - self.control = Controller(self.main) + self.main = Frame(None) + self.control = Controller(self.main) - self.fc = wx.FutureCall(1, self.ShowMain) + self.fc = wx.FutureCall(1, self.ShowMain) def OnClose(self, evt): # Make sure the default handler runs too so this window gets -- libgit2 0.21.2