1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-23 16:08:07 +02:00

AudacityMessageDialog takes TranslatableString message and caption

This commit is contained in:
Paul Licameli 2019-12-17 19:40:32 -05:00
parent 1b726f4f09
commit 71e9e38083
9 changed files with 93 additions and 59 deletions

View File

@ -1017,11 +1017,12 @@ void MacrosWindow::OnRemove(wxCommandEvent & WXUNUSED(event))
} }
wxString name = mMacros->GetItemText(item); wxString name = mMacros->GetItemText(item);
AudacityMessageDialog m(this, AudacityMessageDialog m(
this,
/*i18n-hint: %s will be replaced by the name of a file.*/ /*i18n-hint: %s will be replaced by the name of a file.*/
wxString::Format(_("Are you sure you want to delete %s?"), name), XO("Are you sure you want to delete %s?").Format( name ),
GetTitle(), Verbatim( GetTitle() ),
wxYES_NO | wxICON_QUESTION); wxYES_NO | wxICON_QUESTION );
if (m.ShowModal() == wxID_NO) { if (m.ShowModal() == wxID_NO) {
Raise(); Raise();
return; return;

View File

@ -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. //simply chose to use the save as command although the save command would have the effect.
if( !bOwnsNewAupName && wxFileExists(newFileName)) { if( !bOwnsNewAupName && wxFileExists(newFileName)) {
AudacityMessageDialog m( AudacityMessageDialog m(
NULL, nullptr,
_("The project was not saved because the file name provided would overwrite another project.\nPlease try again and select an original name."), XO("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"), XO("Error Saving Project"),
wxOK|wxICON_ERROR); wxOK|wxICON_ERROR );
m.ShowModal(); m.ShowModal();
return false; return false;
} }
@ -854,10 +854,10 @@ For an audio file that will open in other apps, use 'Export'.\n");
if ((bWantSaveCopy||!bPrompt) && filename.FileExists()) { if ((bWantSaveCopy||!bPrompt) && filename.FileExists()) {
// Saving a copy of the project should never overwrite an existing project. // Saving a copy of the project should never overwrite an existing project.
AudacityMessageDialog m( AudacityMessageDialog m(
NULL, nullptr,
_("Saving a copy must not overwrite an existing saved project.\nPlease try again and select an original name."), XO("Saving a copy must not overwrite an existing saved project.\nPlease try again and select an original name."),
_("Error Saving Copy of Project"), XO("Error Saving Copy of Project"),
wxOK|wxICON_ERROR); wxOK|wxICON_ERROR );
m.ShowModal(); m.ShowModal();
return false; return false;
} }
@ -905,10 +905,10 @@ will be irreversibly overwritten."), fName, fName);
{ {
// Overwrite disalowed. The destination project is open in another window. // Overwrite disalowed. The destination project is open in another window.
AudacityMessageDialog m( AudacityMessageDialog m(
NULL, nullptr,
_("The project will not be saved because the selected project is open in another window.\nPlease try again and select an original name."), XO("The project will not saved because the selected project is open in another window.\nPlease try again and select an original name."),
_("Error Saving Project"), XO("Error Saving Project"),
wxOK|wxICON_ERROR); wxOK|wxICON_ERROR );
m.ShowModal(); m.ShowModal();
return false; return false;
} }

View File

@ -335,11 +335,11 @@ void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(even
// unless it is the current project. // unless it is the current project.
if (wxFileExists(fName) && (pProject->GetFileName() != fName)) { if (wxFileExists(fName) && (pProject->GetFileName() != fName)) {
AudacityMessageDialog m( AudacityMessageDialog m(
NULL, nullptr,
_("The selected file name could not be used\nfor Timer Recording because it \ 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."), would overwrite another project.\nPlease try again and select an original name."),
_("Error Saving Timer Recording Project"), XO("Error Saving Timer Recording Project"),
wxOK|wxICON_ERROR); wxOK|wxICON_ERROR );
m.ShowModal(); m.ShowModal();
return; return;
} }
@ -437,16 +437,16 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
sPlannedTime = projectManager.GetHoursMinsString(iMinsRecording); sPlannedTime = projectManager.GetHoursMinsString(iMinsRecording);
// Create the message string // Create the message string
wxString sMessage; auto sMessage = XO(
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"), "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, .Format( sPlannedTime, sRemainingTime );
sRemainingTime);
AudacityMessageDialog dlgMessage(NULL, AudacityMessageDialog dlgMessage(
nullptr,
sMessage, sMessage,
_("Timer Recording Disk Space Warning"), XO("Timer Recording Disk Space Warning"),
wxYES_NO | wxNO_DEFAULT | wxICON_WARNING); wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
if (dlgMessage.ShowModal() != wxID_YES) { if (dlgMessage.ShowModal() != wxID_YES ) {
// User decided not to continue - bail out! // User decided not to continue - bail out!
return; return;
} }

View File

@ -819,15 +819,24 @@ void VoiceKey::CalibrateNoise(const WaveTrack & t, sampleCount start, sampleCoun
mDirectionChangesMean = sumdc / samples; mDirectionChangesMean = sumdc / samples;
mDirectionChangesSD =sqrt(sumdc2 / samples - mDirectionChangesMean * mDirectionChangesMean) ; 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'*/ /* 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 +=
text+= wxString::Format(_("Sign Changes -- mean: %1.4f sd: (%1.4f)\n"),mSignChangesMean,mSignChangesSD); XO("Energy -- mean: %1.4f sd: (%1.4f)\n")
text += wxString::Format(_("Direction Changes -- mean: %1.4f sd: (%1.4f)\n"), mDirectionChangesMean, mDirectionChangesSD); .Format( mEnergyMean, mEnergySD );
AudacityMessageDialog{ NULL, text, text +=
_("Calibration Complete"), 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, wxOK | wxICON_INFORMATION,
wxPoint(-1, -1) } wxPoint(-1, -1)
}
.ShowModal(); .ShowModal();
AdjustThreshold(mThresholdAdjustment); AdjustThreshold(mThresholdAdjustment);

View File

@ -55,12 +55,20 @@ bool ContrastDialog::GetDB(float &dB)
TrackList::Get( *p ).SelectedLeaders< const WaveTrack >(); TrackList::Get( *p ).SelectedLeaders< const WaveTrack >();
auto numberSelectedTracks = range.size(); auto numberSelectedTracks = range.size();
if (numberSelectedTracks > 1) { 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(); m.ShowModal();
return false; return false;
} }
if(numberSelectedTracks == 0) { 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(); m.ShowModal();
return false; return false;
} }
@ -80,14 +88,22 @@ bool ContrastDialog::GetDB(float &dB)
if(SelT0 > SelT1) 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(); m.ShowModal();
return false; return false;
} }
if(SelT0 == SelT1) 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(); m.ShowModal();
return false; return false;
} }

View File

@ -3503,9 +3503,10 @@ void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt))
name = text->GetValue(); name = text->GetValue();
if (name.empty()) if (name.empty())
{ {
AudacityMessageDialog md(this, AudacityMessageDialog md(
_("You must specify a name"), this,
_("Save Preset")); XO("You must specify a name"),
XO("Save Preset") );
md.Center(); md.Center();
md.ShowModal(); md.ShowModal();
continue; continue;
@ -3513,10 +3514,11 @@ void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt))
if ( make_iterator_range( mUserPresets ).contains( name ) ) if ( make_iterator_range( mUserPresets ).contains( name ) )
{ {
AudacityMessageDialog md(this, AudacityMessageDialog md(
_("Preset already exists.\n\nReplace?"), this,
_("Save Preset"), XO("Preset already exists.\n\nReplace?"),
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION); XO("Save Preset"),
wxYES_NO | wxCANCEL | wxICON_EXCLAMATION );
md.Center(); md.Center();
int choice = md.ShowModal(); int choice = md.ShowModal();
if (choice == wxID_CANCEL) if (choice == wxID_CANCEL)

View File

@ -1558,7 +1558,9 @@ bool ProgressDialog::SearchForWindow(const wxWindowList & list, const wxWindow *
void ProgressDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) 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; return;
} }
FindWindowById(wxID_CANCEL, this)->Disable(); FindWindowById(wxID_CANCEL, this)->Disable();
@ -1567,7 +1569,9 @@ void ProgressDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
void ProgressDialog::OnStop(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; return;
} }
FindWindowById(wxID_OK, this)->Disable(); FindWindowById(wxID_OK, this)->Disable();
@ -1577,7 +1581,8 @@ void ProgressDialog::OnStop(wxCommandEvent & WXUNUSED(event))
void ProgressDialog::OnCloseWindow(wxCloseEvent & 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; return;
} }
mCancel = true; mCancel = true;
@ -1616,8 +1621,8 @@ void ProgressDialog::Beep() const
// Confirm action taken by user. // Confirm action taken by user.
// Returns TRUE if the user confirms Yes // Returns TRUE if the user confirms Yes
bool ProgressDialog::ConfirmAction(const wxString & sPrompt, bool ProgressDialog::ConfirmAction(const TranslatableString & sPrompt,
const wxString & sTitle, const TranslatableString & sTitle,
int iButtonID /* = -1 */) { int iButtonID /* = -1 */) {
// Check if confirmations are enabled? // Check if confirmations are enabled?
@ -1626,10 +1631,11 @@ bool ProgressDialog::ConfirmAction(const wxString & sPrompt,
return true; return true;
} }
AudacityMessageDialog dlgMessage(this, AudacityMessageDialog dlgMessage(
this,
sPrompt, sPrompt,
sTitle, sTitle,
wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT | wxSTAY_ON_TOP); wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT | wxSTAY_ON_TOP );
int iAction = dlgMessage.ShowModal(); int iAction = dlgMessage.ShowModal();
bool bReturn = (iAction == wxID_YES); bool bReturn = (iAction == wxID_YES);

View File

@ -133,8 +133,8 @@ private:
void OnCloseWindow(wxCloseEvent & e); void OnCloseWindow(wxCloseEvent & e);
void Beep() const; void Beep() const;
bool ConfirmAction(const wxString & sPrompt, bool ConfirmAction(const TranslatableString & sPrompt,
const wxString & sTitle, const TranslatableString & sTitle,
int iButtonID = -1); int iButtonID = -1);
void AddMessageAsColumn(wxBoxSizer * pSizer, void AddMessageAsColumn(wxBoxSizer * pSizer,

View File

@ -213,12 +213,12 @@ class AudacityMessageDialog : public wxTabTraversalWrapper< wxMessageDialog >
public: public:
AudacityMessageDialog( AudacityMessageDialog(
wxWindow *parent, wxWindow *parent,
const wxString& message, const TranslatableString &message,
const wxString& caption, // don't use = wxMessageBoxCaptionStr, const TranslatableString &caption, // don't use = wxMessageBoxCaptionStr,
long style = wxOK|wxCENTRE, long style = wxOK|wxCENTRE,
const wxPoint& pos = wxDefaultPosition) const wxPoint& pos = wxDefaultPosition)
: wxTabTraversalWrapper< wxMessageDialog> : wxTabTraversalWrapper< wxMessageDialog>
( parent, message, caption, style, pos ) ( parent, message.Translation(), caption.Translation(), style, pos )
{} {}
}; };