made language default to en-US if the we can't figure out the default locale (#12)

This commit is contained in:
Micah Lee 2013-02-21 09:55:26 -08:00
parent 479b9a4455
commit 720470e8ca

View File

@ -62,16 +62,20 @@ class TorBrowserLauncher:
# figure out the language
available_languages = ['en-US', 'ar', 'de', 'es-ES', 'fa', 'fr', 'it', 'ko', 'nl', 'pl', 'pt-PT', 'ru', 'vi', 'zh-CN']
self.language = locale.getdefaultlocale()[0].replace('_', '-')
if self.language not in available_languages:
self.language = self.language.split('-')[0]
if self.language not in available_languages:
for l in available_languages:
if l[0:2] == self.language:
self.language = l
# if language isn't available, default to english
if self.language not in available_languages:
default_locale = locale.getdefaultlocale()[0]
if default_locale == None:
self.language = 'en-US'
else:
self.language = default_locale.replace('_', '-')
if self.language not in available_languages:
self.language = self.language.split('-')[0]
if self.language not in available_languages:
for l in available_languages:
if l[0:2] == self.language:
self.language = l
# if language isn't available, default to english
if self.language not in available_languages:
self.language = 'en-US'
# build all relevant paths
def build_paths(self):