[Nvda-dev] commit r1970 - trunk/source

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

[Nvda-dev] commit r1970 - trunk/source

NVDA Subversion
Author: mdcurran
Date: Sat Apr 26 06:33:48 2008
New Revision: 1970

languagehandler.localeNameToWindowsLCID: if kernel32.dll does not have LocaleNameToLCID (the OS is not Windows Vista or later) manually search Python's locale.windows_locale dictionary to work out the LCID. Much slower, but it should still work.


Modified: trunk/source/languageHandler.py
--- trunk/source/languageHandler.py (original)
+++ trunk/source/languageHandler.py Sat Apr 26 06:33:48 2008
@@ -18,12 +18,20 @@
  @returns: a Windows LCID
  @rtype: integer
- #Windows only excepts full locales (with country included) and uses a dash not underscore
  if '.' in localeName:
- localeName=localeName.replace('_','-')
- LCID=ctypes.windll.kernel32.LocaleNameToLCID(unicode(localeName),0)
+ #Windows Vista is able to convert locale names to LCIDs
+ func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
+ if func_LocaleNameToLCID is not None:
+ localeName=localeName.replace('_','-')
+ LCID=ctypes.windll.kernel32.LocaleNameToLCID(unicode(localeName),0)
+ else: #Windows doesn't have this functionality, manually search Python's windows_locale dictionary for the LCID
+ LCList=[x[0] for x in locale.windows_locale.iteritems() if x[1]==localeName]
+ if len(LCList)>0:
+ LCID=LCList[0]
+ else:
+ LCID=0
  return LCID
 def getAvailableLanguages():