def getAvailableLanguages(): """generates a list of locale names, plus their full localized language and country names. @rtype: list of tuples """ #Make a list of all the locales found in NVDA's locale dir l = [x for x in os.listdir(paths.locale_path()) if not x.startswith('.')] l = [ x for x in l if os.path.isfile(paths.locale_path('%s/LC_MESSAGES/twblue.mo' % x)) ] #Make sure that en (english) is in the list as it may not have any locale files, but is default if 'en' not in l: l.append('en') l.sort() #For each locale, ask Windows for its human readable display name d = [] for i in l: desc = getLanguageDescription(i) label = "%s, %s" % (desc, i) if desc else i d.append(label) #include a 'user default, windows' language, which just represents the default language for this user account l.append("system") # Translators: the label for the Windows default NVDA interface language. d.append(_("User default")) #return a zipped up version of both the lists (a list with tuples of locale,label) return zip(l, d)
def setLanguage(lang): system = platform.system() global curLang try: if lang == "system": if system == "Windows": windowsLCID = ctypes.windll.kernel32.GetUserDefaultUILanguage() localeName = locale.windows_locale[windowsLCID] elif system == "Darwin": import Foundation localeName = Foundation.NSLocale.currentLocale().identifier() elif system == "Linux": localeName = locale.getdefaultlocale()[0] trans = gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName]) curLang = localeName # else: # localeName=locale.getdefaultlocale()[0] # trans=gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName]) # curLang=localeName else: trans = gettext.translation("twblue", localedir=paths.locale_path(), languages=[lang]) curLang = lang localeChanged = False #Try setting Python's locale to lang # try: if system == "Windows": locale.setlocale(locale.LC_ALL, langToWindowsLocale(lang)) localeChanged = True else: locale.setlocale(locale.LC_ALL, lang) localeChanged = True # except: # pass if not localeChanged and '_' in lang: #Python couldn'tsupport the language_country locale, just try language. try: locale.setlocale(locale.LC_ALL, lang.split('_')[0]) except: pass #Set the windows locale for this thread (NVDA core) to this locale. if system == "Windows": LCID = localeNameToWindowsLCID(lang) ctypes.windll.kernel32.SetThreadLocale(LCID) except IOError: trans = gettext.translation("twblue", fallback=True) curLang = "en" trans.install(unicode=True)
def setLanguage(lang): system = platform.system() global curLang try: if lang=="system": if system == "Windows": windowsLCID=ctypes.windll.kernel32.GetUserDefaultUILanguage() localeName=locale.windows_locale[windowsLCID] elif system == "Darwin": import Foundation localeName = Foundation.NSLocale.currentLocale().identifier() elif system == "Linux": localeName = locale.getdefaultlocale()[0] trans=gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName]) curLang=localeName # else: # localeName=locale.getdefaultlocale()[0] # trans=gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName]) # curLang=localeName else: trans=gettext.translation("twblue", localedir=paths.locale_path(), languages=[lang]) curLang=lang localeChanged=False #Try setting Python's locale to lang # try: if system == "Windows": locale.setlocale(locale.LC_ALL, langToWindowsLocale(lang)) localeChanged=True else: locale.setlocale(locale.LC_ALL, lang) localeChanged=True # except: # pass if not localeChanged and '_' in lang: #Python couldn'tsupport the language_country locale, just try language. try: locale.setlocale(locale.LC_ALL, lang.split('_')[0]) except: pass #Set the windows locale for this thread (NVDA core) to this locale. if system == "Windows": LCID=localeNameToWindowsLCID(lang) ctypes.windll.kernel32.SetThreadLocale(LCID) except IOError: trans=gettext.translation("twblue",fallback=True) curLang="en" trans.install(unicode=True)
def getAvailableLanguages(): """generates a list of locale names, plus their full localized language and country names. @rtype: list of tuples """ #Make a list of all the locales found in NVDA's locale dir l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')] l=[x for x in l if os.path.isfile(paths.locale_path('%s/LC_MESSAGES/twblue.mo' % x))] #Make sure that en (english) is in the list as it may not have any locale files, but is default if 'en' not in l: l.append('en') l.sort() #For each locale, ask Windows for its human readable display name d=[] for i in l: desc=getLanguageDescription(i) label="%s, %s"%(desc,i) if desc else i d.append(label) #include a 'user default, windows' language, which just represents the default language for this user account l.append("system") # Translators: the label for the Windows default NVDA interface language. d.append(_("User default")) #return a zipped up version of both the lists (a list with tuples of locale,label) return zip(l,d)
config.MAINFILE = "%s/session.conf" % (manager.manager.get_current_session()) config.setup() lang=config.main['general']['language'] languageHandler.setLanguage(lang) sound.setup() output.setup() configured = True else: ssmg = smGUI.sessionManagerWindow() if configured == True or ssmg.ShowModal() == wx.ID_OK: frame = gui.main.mainFrame() frame.Show() frame.showing = True if config.main != None and config.main["general"]["hide_gui"] == True and platform.system() == "Windows": frame.show_hide() frame.Hide() app.SetTopWindow(frame) else: app.Exit() ### I should uncomment this #if platform.system() != "Windows": if languageHandler.getLanguage() != "en": local = wx.Locale(wxLangs.getLanguage()) local.AddCatalogLookupPathPrefix(paths.locale_path()) local.AddCatalog("twblue") #languageHandler.setLanguage(lang) #ap = app(redirect=True, useBestVisual=True, filename=paths.logs_path('tracebacks.log')) #wx.CallLater(10, start) app.MainLoop()
manager.manager.get_current_session()) config.setup() lang = config.main['general']['language'] languageHandler.setLanguage(lang) sound.setup() output.setup() configured = True else: ssmg = smGUI.sessionManagerWindow() if configured == True or ssmg.ShowModal() == wx.ID_OK: frame = gui.main.mainFrame() frame.Show() frame.showing = True if config.main != None and config.main["general"][ "hide_gui"] == True and platform.system() == "Windows": frame.show_hide() frame.Hide() app.SetTopWindow(frame) else: app.Exit() ### I should uncomment this #if platform.system() != "Windows": if languageHandler.getLanguage() != "en": local = wx.Locale(wxLangs.getLanguage()) local.AddCatalogLookupPathPrefix(paths.locale_path()) local.AddCatalog("twblue") #languageHandler.setLanguage(lang) #ap = app(redirect=True, useBestVisual=True, filename=paths.logs_path('tracebacks.log')) #wx.CallLater(10, start) app.MainLoop()
def available_languages(): return core.available_languages(paths.locale_path(), application.name)
def setup(): logging.info("Initializing the i18n subsystem.") core.set_active_language(application.name, paths.locale_path(), config.main['languages']['current'])
def setup(): logging.info("Initializing the i18n subsystem.") core.set_active_language(application.name, paths.locale_path(), config.conf['general']['language'])