diff options
author | Micah Lee <micah@micahflee.com> | 2018-09-30 17:06:29 -0700 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2018-09-30 17:06:29 -0700 |
commit | c4f776c42ada8b6a8c2c8326dc91d3aa87670675 (patch) | |
tree | 03bd7129b0779bd5229f9267a4e1c39d32771a2b /onionshare_gui | |
parent | 23c55bc95b2c99a6efad03f0c6c0fda91c18cf26 (diff) | |
download | onionshare-c4f776c42ada8b6a8c2c8326dc91d3aa87670675.tar.gz onionshare-c4f776c42ada8b6a8c2c8326dc91d3aa87670675.zip |
Set OnionShare language based on the locale stored in settings, and prompt user to restart OnionShare after changing their language
Diffstat (limited to 'onionshare_gui')
-rw-r--r-- | onionshare_gui/__init__.py | 4 | ||||
-rw-r--r-- | onionshare_gui/onionshare_gui.py | 5 | ||||
-rw-r--r-- | onionshare_gui/settings_dialog.py | 30 |
3 files changed, 28 insertions, 11 deletions
diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py index 99db635a..51565cb6 100644 --- a/onionshare_gui/__init__.py +++ b/onionshare_gui/__init__.py @@ -59,7 +59,11 @@ def main(): common = Common() common.define_css() + # Load settings right away, in order to get locale setting for strings + common.load_settings() strings.load_strings(common) + + # Display OnionShare banner print(strings._('version_string').format(common.version)) # Allow Ctrl-C to smoothly quit the program instead of throwing an exception diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 83f3a7e0..b3d6afef 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -57,9 +57,10 @@ class OnionShareGui(QtWidgets.QMainWindow): self.setWindowIcon(QtGui.QIcon(self.common.get_resource_path('images/logo.png'))) self.setMinimumWidth(850) - # Load settings + # Load settings, if a custom config was passed in self.config = config - self.common.load_settings(self.config) + if self.config: + self.common.load_settings(self.config) # System tray menu = QtWidgets.QMenu() diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 709ab059..7aff85a5 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -830,8 +830,29 @@ class SettingsDialog(QtWidgets.QDialog): """ self.common.log('SettingsDialog', 'save_clicked') + def changed(s1, s2, keys): + """ + Compare the Settings objects s1 and s2 and return true if any values + have changed for the given keys. + """ + for key in keys: + if s1.get(key) != s2.get(key): + return True + return False + settings = self.settings_from_fields() if settings: + # If language changed, inform user they need to restart OnionShare + if changed(settings, self.old_settings, ['locale']): + # Look up error message in different locale + new_locale = settings.get('locale') + if new_locale in strings.translations and 'gui_settings_language_changed_notice' in strings.translations[new_locale]: + notice = strings.translations[new_locale]['gui_settings_language_changed_notice'] + else: + notice = strings._('gui_settings_language_changed_notice') + Alert(self.common, notice, QtWidgets.QMessageBox.Information) + + # Save the new settings settings.save() # If Tor isn't connected, or if Tor settings have changed, Reinitialize @@ -840,15 +861,6 @@ class SettingsDialog(QtWidgets.QDialog): if not self.local_only: if self.onion.is_authenticated(): self.common.log('SettingsDialog', 'save_clicked', 'Connected to Tor') - def changed(s1, s2, keys): - """ - Compare the Settings objects s1 and s2 and return true if any values - have changed for the given keys. - """ - for key in keys: - if s1.get(key) != s2.get(key): - return True - return False if changed(settings, self.old_settings, [ 'connection_type', 'control_port_address', |