[tuxdroid-user] Automatically detect language
Status: Beta
Brought to you by:
ks156
From: Georges D. <geo...@la...> - 2007-08-08 13:14:02
|
Hi I just wrote a little piece of code that read the locale in order to determine which language tux should speak. Here it is : def find_language(): env=os.environ['LANG'] dict1={ 'en_US':'US', #American English 'nl_BE':'B'} #Belgian Dutch dict2={ 'fr':'FR', #French 'de':'D', #Deutsch 'en':'GB', #British English 'ar':'AR', #Arabic 'da':'DK', #Danish 'es':'E', #Spanish 'it':'I', #Italian 'nl':'NL', #Dutch 'nb':'NO', #Norwegian 'pt':'P', #Portuguese 'sv':'S'} #Swedish if dict1.has_key(env[:5]): return dict1[env[:5]] elif dict2.has_key(env[:2]): return dict2[env[:2]] else: return 'US' I think it can be useful. Maybe even in the svn (in order to determine default language, and advice about downloading languages). What do you think about it ? |