From 71e9e380830d8df44c765050ac6ff0b098d0eddf Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 17 Dec 2019 19:40:32 -0500 Subject: [PATCH] AudacityMessageDialog takes TranslatableString message and caption --- src/BatchProcessDialog.cpp | 11 ++++++----- src/ProjectFileManager.cpp | 24 ++++++++++++------------ src/TimerRecordDialog.cpp | 22 +++++++++++----------- src/VoiceKey.cpp | 25 +++++++++++++++++-------- src/effects/Contrast.cpp | 24 ++++++++++++++++++++---- src/effects/Effect.cpp | 16 +++++++++------- src/widgets/ProgressDialog.cpp | 20 +++++++++++++------- src/widgets/ProgressDialog.h | 4 ++-- src/widgets/wxPanelWrapper.h | 6 +++--- 9 files changed, 93 insertions(+), 59 deletions(-) diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index 1f209a84d..58f294cc7 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -1017,11 +1017,12 @@ void MacrosWindow::OnRemove(wxCommandEvent & WXUNUSED(event)) } wxString name = mMacros->GetItemText(item); - AudacityMessageDialog m(this, - /*i18n-hint: %s will be replaced by the name of a file.*/ - wxString::Format(_("Are you sure you want to delete %s?"), name), - GetTitle(), - wxYES_NO | wxICON_QUESTION); + AudacityMessageDialog m( + this, + /*i18n-hint: %s will be replaced by the name of a file.*/ + XO("Are you sure you want to delete %s?").Format( name ), + Verbatim( GetTitle() ), + wxYES_NO | wxICON_QUESTION ); if (m.ShowModal() == wxID_NO) { Raise(); return; diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index 4e0f5a4d7..50296b13f 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -729,10 +729,10 @@ bool ProjectFileManager::SaveAs(const wxString & newFileName, bool bWantSaveCopy //simply chose to use the save as command although the save command would have the effect. if( !bOwnsNewAupName && wxFileExists(newFileName)) { AudacityMessageDialog m( - NULL, - _("The project was not saved because the file name provided would overwrite another project.\nPlease try again and select an original name."), - _("Error Saving Project"), - wxOK|wxICON_ERROR); + nullptr, + XO("The project was not saved because the file name provided would overwrite another project.\nPlease try again and select an original name."), + XO("Error Saving Project"), + wxOK|wxICON_ERROR ); m.ShowModal(); return false; } @@ -854,10 +854,10 @@ For an audio file that will open in other apps, use 'Export'.\n"); if ((bWantSaveCopy||!bPrompt) && filename.FileExists()) { // Saving a copy of the project should never overwrite an existing project. AudacityMessageDialog m( - NULL, - _("Saving a copy must not overwrite an existing saved project.\nPlease try again and select an original name."), - _("Error Saving Copy of Project"), - wxOK|wxICON_ERROR); + nullptr, + XO("Saving a copy must not overwrite an existing saved project.\nPlease try again and select an original name."), + XO("Error Saving Copy of Project"), + wxOK|wxICON_ERROR ); m.ShowModal(); return false; } @@ -905,10 +905,10 @@ will be irreversibly overwritten."), fName, fName); { // Overwrite disalowed. The destination project is open in another window. AudacityMessageDialog m( - NULL, - _("The project will not be saved because the selected project is open in another window.\nPlease try again and select an original name."), - _("Error Saving Project"), - wxOK|wxICON_ERROR); + nullptr, + XO("The project will not saved because the selected project is open in another window.\nPlease try again and select an original name."), + XO("Error Saving Project"), + wxOK|wxICON_ERROR ); m.ShowModal(); return false; } diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 545717231..812c21388 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -335,11 +335,11 @@ void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(even // unless it is the current project. if (wxFileExists(fName) && (pProject->GetFileName() != fName)) { AudacityMessageDialog m( - NULL, - _("The selected file name could not be used\nfor Timer Recording because it \ + nullptr, + XO("The selected file name could not be used\nfor Timer Recording because it \ would overwrite another project.\nPlease try again and select an original name."), - _("Error Saving Timer Recording Project"), - wxOK|wxICON_ERROR); + XO("Error Saving Timer Recording Project"), + wxOK|wxICON_ERROR ); m.ShowModal(); return; } @@ -437,16 +437,16 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event)) sPlannedTime = projectManager.GetHoursMinsString(iMinsRecording); // Create the message string - wxString sMessage; - sMessage.Printf(_("You may not have enough free disk space to complete this Timer Recording, based on your current settings.\n\nDo you wish to continue?\n\nPlanned recording duration: %s\nRecording time remaining on disk: %s"), - sPlannedTime, - sRemainingTime); + auto sMessage = XO( +"You may not have enough free disk space to complete this Timer Recording, based on your current settings.\n\nDo you wish to continue?\n\nPlanned recording duration: %s\nRecording time remaining on disk: %s") + .Format( sPlannedTime, sRemainingTime ); - AudacityMessageDialog dlgMessage(NULL, + AudacityMessageDialog dlgMessage( + nullptr, sMessage, - _("Timer Recording Disk Space Warning"), + XO("Timer Recording Disk Space Warning"), wxYES_NO | wxNO_DEFAULT | wxICON_WARNING); - if (dlgMessage.ShowModal() != wxID_YES) { + if (dlgMessage.ShowModal() != wxID_YES ) { // User decided not to continue - bail out! return; } diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp index 5e4e01038..22fe1cded 100644 --- a/src/VoiceKey.cpp +++ b/src/VoiceKey.cpp @@ -819,16 +819,25 @@ void VoiceKey::CalibrateNoise(const WaveTrack & t, sampleCount start, sampleCoun mDirectionChangesMean = sumdc / samples; mDirectionChangesSD =sqrt(sumdc2 / samples - mDirectionChangesMean * mDirectionChangesMean) ; - wxString text = _("Calibration Results\n"); + auto text = XO("Calibration Results\n"); /* i18n-hint: %1.4f is replaced by a number. sd stands for 'Standard Deviations'*/ - text += wxString::Format(_("Energy -- mean: %1.4f sd: (%1.4f)\n"),mEnergyMean,mEnergySD); - text+= wxString::Format(_("Sign Changes -- mean: %1.4f sd: (%1.4f)\n"),mSignChangesMean,mSignChangesSD); - text += wxString::Format(_("Direction Changes -- mean: %1.4f sd: (%1.4f)\n"), mDirectionChangesMean, mDirectionChangesSD); - AudacityMessageDialog{ NULL, text, - _("Calibration Complete"), + text += + XO("Energy -- mean: %1.4f sd: (%1.4f)\n") + .Format( mEnergyMean, mEnergySD ); + text += + XO("Sign Changes -- mean: %1.4f sd: (%1.4f)\n") + .Format( mSignChangesMean, mSignChangesSD ); + text += + XO("Direction Changes -- mean: %1.4f sd: (%1.4f)\n") + .Format( mDirectionChangesMean, mDirectionChangesSD ); + AudacityMessageDialog{ + nullptr, + text, + XO("Calibration Complete"), wxOK | wxICON_INFORMATION, - wxPoint(-1, -1) } - .ShowModal(); + wxPoint(-1, -1) + } + .ShowModal(); AdjustThreshold(mThresholdAdjustment); } diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 5b5479763..1eb3d0698 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -55,12 +55,20 @@ bool ContrastDialog::GetDB(float &dB) TrackList::Get( *p ).SelectedLeaders< const WaveTrack >(); auto numberSelectedTracks = range.size(); if (numberSelectedTracks > 1) { - AudacityMessageDialog m(NULL, _("You can only measure one track at a time."), _("Error"), wxOK); + AudacityMessageDialog m( + nullptr, + XO("You can only measure one track at a time."), + XO("Error"), + wxOK); m.ShowModal(); return false; } if(numberSelectedTracks == 0) { - AudacityMessageDialog m(NULL, _("Please select an audio track."), _("Error"), wxOK); + AudacityMessageDialog m( + nullptr, + XO("Please select an audio track."), + XO("Error"), + wxOK); m.ShowModal(); return false; } @@ -80,14 +88,22 @@ bool ContrastDialog::GetDB(float &dB) if(SelT0 > SelT1) { - AudacityMessageDialog m(NULL, _("Invalid audio selection.\nPlease ensure that audio is selected."), _("Error"), wxOK); + AudacityMessageDialog m( + nullptr, + XO("Invalid audio selection.\nPlease ensure that audio is selected."), + XO("Error"), + wxOK); m.ShowModal(); return false; } if(SelT0 == SelT1) { - AudacityMessageDialog m(NULL, _("Nothing to measure.\nPlease select a section of a track."), _("Error"), wxOK); + AudacityMessageDialog m( + nullptr, + XO("Nothing to measure.\nPlease select a section of a track."), + XO("Error"), + wxOK); m.ShowModal(); return false; } diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 5d5b32fdb..c8e08df5f 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -3503,9 +3503,10 @@ void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt)) name = text->GetValue(); if (name.empty()) { - AudacityMessageDialog md(this, - _("You must specify a name"), - _("Save Preset")); + AudacityMessageDialog md( + this, + XO("You must specify a name"), + XO("Save Preset") ); md.Center(); md.ShowModal(); continue; @@ -3513,10 +3514,11 @@ void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt)) if ( make_iterator_range( mUserPresets ).contains( name ) ) { - AudacityMessageDialog md(this, - _("Preset already exists.\n\nReplace?"), - _("Save Preset"), - wxYES_NO | wxCANCEL | wxICON_EXCLAMATION); + AudacityMessageDialog md( + this, + XO("Preset already exists.\n\nReplace?"), + XO("Save Preset"), + wxYES_NO | wxCANCEL | wxICON_EXCLAMATION ); md.Center(); int choice = md.ShowModal(); if (choice == wxID_CANCEL) diff --git a/src/widgets/ProgressDialog.cpp b/src/widgets/ProgressDialog.cpp index ac55f9f37..4b6a215be 100644 --- a/src/widgets/ProgressDialog.cpp +++ b/src/widgets/ProgressDialog.cpp @@ -1558,7 +1558,9 @@ bool ProgressDialog::SearchForWindow(const wxWindowList & list, const wxWindow * void ProgressDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) { - if (!ConfirmAction(_("Are you sure you wish to cancel?"), _("Confirm Cancel"), wxID_CANCEL)) { + if (!ConfirmAction( + XO("Are you sure you wish to cancel?"), + XO("Confirm Cancel"), wxID_CANCEL)) { return; } FindWindowById(wxID_CANCEL, this)->Disable(); @@ -1567,7 +1569,9 @@ void ProgressDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) void ProgressDialog::OnStop(wxCommandEvent & WXUNUSED(event)) { - if (!ConfirmAction(_("Are you sure you wish to stop?"), _("Confirm Stop"), wxID_OK)) { + if (!ConfirmAction( + XO("Are you sure you wish to stop?"), + XO("Confirm Stop"), wxID_OK)) { return; } FindWindowById(wxID_OK, this)->Disable(); @@ -1577,7 +1581,8 @@ void ProgressDialog::OnStop(wxCommandEvent & WXUNUSED(event)) void ProgressDialog::OnCloseWindow(wxCloseEvent & WXUNUSED(event)) { - if (!ConfirmAction(_("Are you sure you wish to close?"), _("Confirm Close"))) { + if (!ConfirmAction( + XO("Are you sure you wish to close?"), XO("Confirm Close"))) { return; } mCancel = true; @@ -1616,8 +1621,8 @@ void ProgressDialog::Beep() const // Confirm action taken by user. // Returns TRUE if the user confirms Yes -bool ProgressDialog::ConfirmAction(const wxString & sPrompt, - const wxString & sTitle, +bool ProgressDialog::ConfirmAction(const TranslatableString & sPrompt, + const TranslatableString & sTitle, int iButtonID /* = -1 */) { // Check if confirmations are enabled? @@ -1626,10 +1631,11 @@ bool ProgressDialog::ConfirmAction(const wxString & sPrompt, return true; } - AudacityMessageDialog dlgMessage(this, + AudacityMessageDialog dlgMessage( + this, sPrompt, sTitle, - wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT | wxSTAY_ON_TOP); + wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT | wxSTAY_ON_TOP ); int iAction = dlgMessage.ShowModal(); bool bReturn = (iAction == wxID_YES); diff --git a/src/widgets/ProgressDialog.h b/src/widgets/ProgressDialog.h index 075907db6..7f45cc292 100644 --- a/src/widgets/ProgressDialog.h +++ b/src/widgets/ProgressDialog.h @@ -133,8 +133,8 @@ private: void OnCloseWindow(wxCloseEvent & e); void Beep() const; - bool ConfirmAction(const wxString & sPrompt, - const wxString & sTitle, + bool ConfirmAction(const TranslatableString & sPrompt, + const TranslatableString & sTitle, int iButtonID = -1); void AddMessageAsColumn(wxBoxSizer * pSizer, diff --git a/src/widgets/wxPanelWrapper.h b/src/widgets/wxPanelWrapper.h index 922fc6fd4..d9490b666 100644 --- a/src/widgets/wxPanelWrapper.h +++ b/src/widgets/wxPanelWrapper.h @@ -213,12 +213,12 @@ class AudacityMessageDialog : public wxTabTraversalWrapper< wxMessageDialog > public: AudacityMessageDialog( wxWindow *parent, - const wxString& message, - const wxString& caption, // don't use = wxMessageBoxCaptionStr, + const TranslatableString &message, + const TranslatableString &caption, // don't use = wxMessageBoxCaptionStr, long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition) : wxTabTraversalWrapper< wxMessageDialog> - ( parent, message, caption, style, pos ) + ( parent, message.Translation(), caption.Translation(), style, pos ) {} };