Tor Browser Launcher
https://github.com/micahflee/torbrowser-launcher/
-Copyright (c) 2013-2017 Micah Lee <micah@micahflee.com>
+Copyright (c) 2013-2021 Micah Lee <micah@micahflee.com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
available_languages = [
"ar",
"ca",
+ "cs",
"da",
"de",
+ "el",
"en-US",
+ "es-AR",
"es-ES",
"fa",
"fr",
"ga-IE",
"he",
+ "hu",
"id",
"is",
"it",
"ja",
+ "ka",
"ko",
+ "lt",
+ "mk",
+ "ms",
+ "my",
"nb-NO",
"nl",
"pl",
"pt-BR",
+ "ro",
"ru",
"sv-SE",
+ "th",
"tr",
"vi",
"zh-CN",
"zh-TW",
]
- default_locale = locale.getlocale()[0]
+
+ # a list of manually configured language fallback overriding
+ language_overrides = {
+ "zh-HK": "zh-TW",
+ }
+
+ locale.setlocale(locale.LC_MESSAGES, "")
+ default_locale = locale.getlocale(locale.LC_MESSAGES)[0]
if default_locale is None:
self.language = "en-US"
else:
self.language = default_locale.replace("_", "-")
+ if self.language in language_overrides:
+ self.language = language_overrides[self.language]
if self.language not in available_languages:
self.language = self.language.split("-")[0]
if self.language not in available_languages:
if self.language not in available_languages:
self.language = "en-US"
+ # get value of environment variable, if it is not set return the default value
+ @staticmethod
+ def get_env(var_name, default_value):
+ value = os.getenv(var_name)
+ if not value:
+ value = default_value
+ return value
+
# build all relevant paths
def build_paths(self, tbb_version=None):
homedir = os.getenv("HOME")
self.set_gui(
"error", _("Error creating {0}").format(homedir), [], False
)
- if not os.access(homedir, os.W_OK):
- self.set_gui("error", _("{0} is not writable").format(homedir), [], False)
- tbb_config = "{0}/.config/torbrowser".format(homedir)
- tbb_cache = "{0}/.cache/torbrowser".format(homedir)
- tbb_local = "{0}/.local/share/torbrowser".format(homedir)
+ tbb_config = "{0}/torbrowser".format(
+ self.get_env("XDG_CONFIG_HOME", "{0}/.config".format(homedir))
+ )
+ tbb_cache = "{0}/torbrowser".format(
+ self.get_env("XDG_CACHE_HOME", "{0}/.cache".format(homedir))
+ )
+ tbb_local = "{0}/torbrowser".format(
+ self.get_env("XDG_DATA_HOME", "{0}/.local/share".format(homedir))
+ )
old_tbb_data = "{0}/.torbrowser".format(homedir)
if tbb_version:
self.paths["sig_filename"] = tarball_filename + ".asc"
else:
self.paths = {
- "dirs": {"config": tbb_config, "cache": tbb_cache, "local": tbb_local,},
+ "dirs": {
+ "config": tbb_config,
+ "cache": tbb_cache,
+ "local": tbb_local,
+ },
"old_data_dir": old_tbb_data,
"tbl_bin": sys.argv[0],
"icon_file": os.path.join(
# Fetch key from wkd, as per https://support.torproject.org/tbb/how-to-verify-signature/
p = subprocess.Popen(
[
- "/usr/bin/gpg2",
+ "gpg",
"--status-fd",
"2",
"--homedir",