def __TranslateMessage__(self): """Translate Messages of the Window""" os_language = i18n.GetLocaleOS() if os_language[0:2] == "pt": _ = i18n.InstallLanguage("pt_BR") elif os_language[0:2] == "es": _ = i18n.InstallLanguage("es") else: _ = i18n.InstallLanguage("en")
def __TranslateMessage__(self): """Translate Messages of the Window""" os_language = i18n.GetLocaleOS() if (os_language[0:2] == 'pt'): _ = i18n.InstallLanguage('pt_BR') elif (os_language[0:2] == 'es'): _ = i18n.InstallLanguage('es') else: _ = i18n.InstallLanguage('en')
def non_gui_startup(options, args): lang = 'en' _ = i18n.InstallLanguage(lang) from invesalius.control import Controller from invesalius.project import Project session = ses.Session() if not session.ReadSession(): session.CreateItens() session.SetLanguage(lang) session.WriteSessionFile() control = Controller(None) use_cmd_optargs(options, args)
def __init__(self): # Splash screen image will depend on currently language lang = False self.locale = wx.Locale(wx.LANGUAGE_DEFAULT) # Language information is available in session configuration # file. First we need to check if this file exist, if now, it # should be created create_session = False session = ses.Session() if not (session.ReadSession()): create_session = True install_lang = 0 lang = session.GetLanguage() if lang: if (lang != "False"): _ = i18n.InstallLanguage(lang) install_lang = 1 else: install_lang = 0 else: install_lang = 0 # If no language is set into session file, show dialog so # user can select language if install_lang == 0: dialog = lang_dlg.LanguageDialog() # FIXME: This works ok in linux2, darwin and win32, # except on win64, due to wxWidgets bug try: ok = (dialog.ShowModal() == wx.ID_OK) except wx._core.PyAssertionError: ok = True finally: if ok: lang = dialog.GetSelectedLanguage() session.SetLanguage(lang) _ = i18n.InstallLanguage(lang) else: homedir = self.homedir = os.path.expanduser('~') invdir = os.path.join(homedir, ".invesalius") shutil.rmtree(invdir) sys.exit() dialog.Destroy() # Session file should be created... So we set the recent # choosen language if (create_session): session.CreateItens() session.SetLanguage(lang) session.WriteSessionFile() # session.SaveConfigFileBackup() # Only after language was defined, splash screen will be # shown if lang: #import locale #try: # locale.setlocale(locale.LC_ALL, '') #except locale.Error: # pass # For pt_BR, splash_pt.png should be used if (lang.startswith('pt')): icon_file = "splash_pt.png" else: icon_file = "splash_" + lang + ".png" if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ or sys.frozen == "console_exe"): abs_file_path = os.path.abspath(".." + os.sep) path = abs_file_path path = os.path.join(path, 'icons', icon_file) else: path = os.path.join(".","icons", icon_file) if not os.path.exists(path): path = os.path.join(".", "icons", "splash_en.png") bmp = wx.Image(path).ConvertToBitmap() try: style = wx.adv.SPLASH_TIMEOUT | wx.adv.SPLASH_CENTRE_ON_SCREEN except AttributeError: style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN SplashScreen.__init__(self, bitmap=bmp, splashStyle=style, milliseconds=1500, id=-1, parent=None) self.Bind(wx.EVT_CLOSE, self.OnClose) wx.Yield() wx.CallLater(200, self.Startup)
if sys.platform in ('linux2', 'linux', 'win32'): try: tmp_var = wx.GetXDisplay except AttributeError: # A workaround to make InVesalius run with wxPython4 from Ubuntu 18.04 wx.GetXDisplay = lambda: None else: del tmp_var session = ses.Session() if session.ReadSession(): lang = session.GetLanguage() if lang: LANG = lang try: _ = i18n.InstallLanguage(lang) except FileNotFoundError: LANG = None class InVesalius(wx.App): """ InVesalius wxPython application class. """ def OnInit(self): """ Initialize splash screen and main frame. """ from multiprocessing import freeze_support freeze_support()