Avoid using mismatched translations for wxWizard buttons

Cache labels for "Next>" or "Finish" button in wxWizard so that their
translations stay consistent throughout wizard's lifetime: previously,
this button could use a label in a different language if the currently
used translations have changed since the wizard creation, as this label
was recreated on every page change, unlike the other labels which were
only translated once in the very beginning.

Closes https://github.com/wxWidgets/wxWidgets/pull/1000
This commit is contained in:
Silent 2018-10-30 22:01:46 +01:00 committed by Vadim Zeitlin
parent 9a05410470
commit 6fff1c37b5
2 changed files with 9 additions and 2 deletions

View File

@ -132,6 +132,10 @@ protected:
*m_btnNext; // the "Next>" or "Finish" button
wxStaticBitmap *m_statbmp; // the control for the bitmap
// cached labels so their translations stay consistent
wxString m_nextLabel,
m_finishLabel;
// Border around page area sizer requested using SetBorder()
int m_border;

View File

@ -429,7 +429,10 @@ void wxWizard::AddButtonRow(wxBoxSizer *mainColumn)
btnHelp=new wxButton(this, wxID_HELP, wxEmptyString, wxDefaultPosition, wxDefaultSize, buttonStyle);
#endif
m_btnNext = new wxButton(this, wxID_FORWARD, _("&Next >"));
m_nextLabel = _("&Next >");
m_finishLabel = _("&Finish");
m_btnNext = new wxButton(this, wxID_FORWARD, m_nextLabel);
// Avoid Cmd+C closing dialog on Mac.
wxString cancelLabel(_("&Cancel"));
#ifdef __WXMAC__
@ -629,7 +632,7 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
m_btnPrev->Enable(m_page != m_firstpage);
const bool hasNext = HasNextPage(m_page);
const wxString label = hasNext ? _("&Next >") : _("&Finish");
const wxString& label = hasNext ? m_nextLabel : m_finishLabel;
if ( label != m_btnNext->GetLabel() )
m_btnNext->SetLabel(label);