From 6fff1c37b54e272e0c1f6065ee9726258fc9871e Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 30 Oct 2018 22:01:46 +0100 Subject: [PATCH] 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 --- include/wx/generic/wizard.h | 4 ++++ src/generic/wizard.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/wx/generic/wizard.h b/include/wx/generic/wizard.h index 7b820a4f26..2b512ec5e3 100644 --- a/include/wx/generic/wizard.h +++ b/include/wx/generic/wizard.h @@ -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; diff --git a/src/generic/wizard.cpp b/src/generic/wizard.cpp index 666ab84f47..3960216686 100644 --- a/src/generic/wizard.cpp +++ b/src/generic/wizard.cpp @@ -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);