mirror of
https://github.com/onionshare/onionshare.git
synced 2025-09-27 19:41:02 -04:00
Unlocalize CLI strings
This commit is contained in:
parent
e5366bdf0b
commit
a7bbe818bf
7 changed files with 50 additions and 97 deletions
|
@ -26,7 +26,6 @@ import signal
|
|||
from .widgets import Alert
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from onionshare import strings
|
||||
from onionshare.common import Common
|
||||
from onionshare.onion import Onion
|
||||
from onionshare.onionshare import OnionShare
|
||||
|
@ -59,16 +58,8 @@ def main():
|
|||
common = Common()
|
||||
common.define_css()
|
||||
|
||||
# Load the default settings and strings early, for the sake of being able to parse options.
|
||||
# These won't be in the user's chosen locale necessarily, but we need to parse them
|
||||
# early in order to even display the option to pass alternate settings (which might
|
||||
# contain a preferred locale).
|
||||
# If an alternate --config is passed, we'll reload strings later.
|
||||
common.load_settings()
|
||||
strings.load_strings(common)
|
||||
|
||||
# Display OnionShare banner
|
||||
print(strings._('version_string').format(common.version))
|
||||
print("OnionShare {0:s} | https://onionshare.org/".format(common.version))
|
||||
|
||||
# Allow Ctrl-C to smoothly quit the program instead of throwing an exception
|
||||
# https://stackoverflow.com/questions/42814093/how-to-handle-ctrlc-in-python-app-with-pyqt
|
||||
|
@ -80,10 +71,10 @@ def main():
|
|||
|
||||
# Parse arguments
|
||||
parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.HelpFormatter(prog,max_help_position=48))
|
||||
parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only"))
|
||||
parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', help=strings._("help_verbose"))
|
||||
parser.add_argument('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename'))
|
||||
parser.add_argument('--config', metavar='config', default=False, help=strings._('help_config'))
|
||||
parser.add_argument('--local-only', action='store_true', dest='local_only', help="Don't use Tor (only for development)")
|
||||
parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', help="Log OnionShare errors to stdout, and web errors to disk")
|
||||
parser.add_argument('--filenames', metavar='filenames', nargs='+', help="List of files or folders to share")
|
||||
parser.add_argument('--config', metavar='config', default=False, help="Custom JSON config file location (optional)")
|
||||
args = parser.parse_args()
|
||||
|
||||
filenames = args.filenames
|
||||
|
@ -93,9 +84,7 @@ def main():
|
|||
|
||||
config = args.config
|
||||
if config:
|
||||
# Re-load the strings, in case the provided config has changed locale
|
||||
common.load_settings(config)
|
||||
strings.load_strings(common)
|
||||
|
||||
local_only = bool(args.local_only)
|
||||
verbose = bool(args.verbose)
|
||||
|
@ -108,10 +97,10 @@ def main():
|
|||
valid = True
|
||||
for filename in filenames:
|
||||
if not os.path.isfile(filename) and not os.path.isdir(filename):
|
||||
Alert(common, strings._("not_a_file").format(filename))
|
||||
Alert(common, "{0:s} is not a valid file.".format(filename))
|
||||
valid = False
|
||||
if not os.access(filename, os.R_OK):
|
||||
Alert(common, strings._("not_a_readable_file").format(filename))
|
||||
Alert(common, "{0:s} is not a readable file.".format(filename))
|
||||
valid = False
|
||||
if not valid:
|
||||
sys.exit()
|
||||
|
|
|
@ -62,6 +62,10 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||
self.config = config
|
||||
if self.config:
|
||||
self.common.load_settings(self.config)
|
||||
else:
|
||||
self.common.load_settings()
|
||||
|
||||
strings.load_strings(self.common)
|
||||
|
||||
# System tray
|
||||
menu = QtWidgets.QMenu()
|
||||
|
|
|
@ -25,7 +25,7 @@ from distutils.version import LooseVersion as Version
|
|||
from onionshare.settings import Settings
|
||||
from onionshare.onion import Onion
|
||||
|
||||
from . import strings
|
||||
from onionshare import strings
|
||||
|
||||
class UpdateCheckerCheckError(Exception):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue