Skip to content

Commit

Permalink
Improve restart confirmation dialog after changing interface language
Browse files Browse the repository at this point in the history
  • Loading branch information
aaclause committed Aug 15, 2018
1 parent 671b202 commit fc904b7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
56 changes: 47 additions & 9 deletions source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,15 +773,53 @@ def onSave(self):
updateCheck.initialize()

def postSave(self):
if self.oldLanguage!=config.conf["general"]["language"]:
if gui.messageBox(
# Translators: The message displayed after NVDA interface language has been changed.
_("For the new language to take effect, the configuration must be saved and NVDA must be restarted. Press enter to save and restart NVDA, or cancel to manually save and exit at a later time."),
# Translators: The title of the dialog which appears when the user changed NVDA's interface language.
_("Language Configuration Change"),wx.OK|wx.CANCEL|wx.ICON_WARNING,self
)==wx.OK:
config.conf.save()
queueHandler.queueFunction(queueHandler.eventQueue,core.restart)
if self.oldLanguage != config.conf["general"]["language"]:
LanguageRestartDialog(self, self.oldLanguage).ShowModal()

class LanguageRestartDialog(wx.Dialog):

def __init__(self, parent, oldLanguage):
# Translators: The title of the dialog which appears when the user changed NVDA's interface language.
super(LanguageRestartDialog, self).__init__(parent, title=_("Language Configuration Change"))
mainSizer = wx.BoxSizer(wx.VERTICAL)
sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL)
# Translators: The message displayed after NVDA interface language has been changed.
message = _(
"NVDA must be restarted for the new language to take effect.\n"
"Select \"restart now\" to restart NVDA and use NVDA in {newLanguage}, or \"restart later\" to continue using NVDA in {currentLanguage} until the next restart."
).format(
newLanguage=self.getLanguageDescription(config.conf["general"]["language"]),
currentLanguage=self.getLanguageDescription(oldLanguage)
)
sHelper.addItem(wx.StaticText(self, label=message))

bHelper = sHelper.addDialogDismissButtons(guiHelper.ButtonHelper(wx.HORIZONTAL))
# Translators: The label for a button in the dialog which appears when the user changed NVDA's interface language.
restartNowButton = bHelper.addButton(self, label=_("Restart &now"))
restartNowButton.Bind(wx.EVT_BUTTON, self.onRestartNowButton)
restartNowButton.SetFocus()

# Translators: The label for a button in the dialog which appears when the user changed NVDA's interface language.
restartLaterButton = bHelper.addButton(self, wx.ID_CLOSE, label=_("Restart &later"))
restartLaterButton.Bind(wx.EVT_BUTTON, lambda evt: self.Close())
self.Bind(wx.EVT_CLOSE, lambda evt: self.Destroy())
self.EscapeId = wx.ID_CLOSE

mainSizer.Add(sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
self.Sizer = mainSizer
mainSizer.Fit(self)
self.CentreOnScreen()

def onRestartNowButton(self, evt):
self.Destroy()
config.conf.save()
queueHandler.queueFunction(queueHandler.eventQueue,core.restart)

@staticmethod
def getLanguageDescription(lang):
if lang == "Windows":
lang = languageHandler.getWindowsLanguage()
return languageHandler.getLanguageDescription(languageHandler.normalizeLanguage(lang))

class SpeechSettingsPanel(SettingsPanel):
# Translators: This is the label for the speech panel
Expand Down
3 changes: 1 addition & 2 deletions user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,7 @@ There are many languages, however the default option is "User Default, Windows".
This option tells NVDA to use the language that Windows is currently set to.

Please note that NVDA must be restarted when changing the language.
NVDA will ask you if you wish to restart if you do change the selection and save your changes.
Press OK, and NVDA will restart.
When the confirmation dialog appears, select "restart now" or "restart later" if you wish to use the new language now or at a later time, respectively.

==== Save configuration on exit ====[GeneralSettingsSaveConfig]
This option is a checkbox that, when checked, tells NVDA to automatically save the current configuration when you exit NVDA.
Expand Down

0 comments on commit fc904b7

Please sign in to comment.