[Nvda-dev] commit r1965 - trunk/source

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Nvda-dev] commit r1965 - trunk/source

NVDA Subversion
Author: mdcurran
Date: Fri Apr 25 05:49:10 2008
New Revision: 1965

Log:
languageHandler.setLanguage: a part from loading the right gettext data for the selected language, also try and set Python's locale, and the Windows locale for the current thread, to this language. This for some reason still doesn't make wx locales work in all situations, but it does now mean that if you set NVDA's language to say... french, when its English Windows by default, the time and date script will announce propery with french day names and formatting etc. I'm sure this may also allow for some other locale-specific stuff that I can't think of right now.

Modified:
   trunk/source/languageHandler.py

Modified: trunk/source/languageHandler.py
==============================================================================
--- trunk/source/languageHandler.py (original)
+++ trunk/source/languageHandler.py Fri Apr 25 05:49:10 2008
@@ -3,6 +3,7 @@
 import ctypes
 import locale
 import gettext
+import globalVars
 
 curLang="en"
 
@@ -25,6 +26,29 @@
  else:
  gettext.translation("nvda", localedir="locale", languages=[lang]).install(True)
  curLang=lang
+ localeChanged=False
+ #Try setting Python's locale to lang
+ try:
+ 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.
+ #To convert to windows locale, the language must be language_country, not just language
+ tempLang=locale.normalize(lang)
+ if '.' in tempLang:
+ #There was charset info given, wrip that out
+ tempLang=tempLang.split('.')[0]
+ #Find the windows LC ID for this locale
+ LCList=[x[0] for x in locale.windows_locale.iteritems() if x[1]==tempLang]
+ if len(LCList)>0:
+ ctypes.windll.kernel32.SetThreadLocale(LCList[0])
  config.conf["general"]["language"]=lang
  return True
  except IOError: