From ae42397d648269146c77629d101103c324357c8d Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 18 Dec 2019 16:32:21 -0500 Subject: [PATCH] FileNames::SelectFile takes TranslatableString for message --- src/AudacityLogger.cpp | 2 +- src/Benchmark.cpp | 2 +- src/FFmpeg.cpp | 3 +-- src/FileNames.cpp | 6 +++--- src/FileNames.h | 2 +- src/FreqWindow.cpp | 2 +- src/LabelDialog.cpp | 4 ++-- src/ProjectFileManager.cpp | 14 +++++++------- src/Tags.cpp | 4 ++-- src/TimerRecordDialog.cpp | 2 +- src/effects/Contrast.cpp | 2 +- src/effects/VST/VSTEffect.cpp | 4 ++-- src/export/ExportCL.cpp | 2 +- src/export/ExportMP3.cpp | 3 +-- src/menus/FileMenus.cpp | 10 +++++----- src/menus/HelpMenus.cpp | 4 ++-- src/prefs/KeyConfigPrefs.cpp | 4 ++-- 17 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/AudacityLogger.cpp b/src/AudacityLogger.cpp index d3b7ecc3e..92d29152b 100644 --- a/src/AudacityLogger.cpp +++ b/src/AudacityLogger.cpp @@ -251,7 +251,7 @@ void AudacityLogger::OnSave(wxCommandEvent & WXUNUSED(e)) wxString fName = _("log.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Save log to:"), + XO("Save log to:"), wxEmptyString, fName, wxT("txt"), diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index 8d4ab354f..af1087e83 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -260,7 +260,7 @@ void BenchmarkDialog::OnSave( wxCommandEvent & WXUNUSED(event)) wxString fName = _("benchmark.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Export Benchmark Data as:"), + XO("Export Benchmark Data as:"), wxEmptyString, fName, wxT("txt"), diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 073692622..8e62a4a14 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -510,11 +510,10 @@ public: void OnBrowse(wxCommandEvent & WXUNUSED(event)) { - wxString question; /* i18n-hint: It's asking for the location of a file, for example, "Where is lame_enc.dll?" - you could translate "Where would I find the file '%s'?" instead if you want. */ - question.Printf(_("Where is '%s'?"), mName); + auto question = XO("Where is '%s'?").Format( mName ); wxString path = FileNames::SelectFile(FileNames::Operation::_None, question, diff --git a/src/FileNames.cpp b/src/FileNames.cpp index 6ce13a2c3..285d7e406 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -462,7 +462,7 @@ void FileNames::UpdateDefaultPath(Operation op, const FilePath &path) wxString FileNames::SelectFile(Operation op, - const wxString& message, + const TranslatableString& message, const FilePath& default_path, const FilePath& default_filename, const wxString& default_extension, @@ -472,7 +472,7 @@ FileNames::SelectFile(Operation op, { return WithDefaultPath(op, default_path, [&](const FilePath &path) { return FileSelector( - message, path, default_filename, default_extension, + message.Translation(), path, default_filename, default_extension, wildcard, flags, parent, wxDefaultCoord, wxDefaultCoord); }); } @@ -618,7 +618,7 @@ char *FileNames::VerifyFilename(const wxString &s, bool input) ext = ff.GetExt(); name = FileNames::SelectFile(FileNames::Operation::_None, - _("Specify New Filename:"), + XO("Specify New Filename:"), wxEmptyString, name, ext, diff --git a/src/FileNames.h b/src/FileNames.h index 0b76100d8..05d4556c3 100644 --- a/src/FileNames.h +++ b/src/FileNames.h @@ -127,7 +127,7 @@ public: static wxString SelectFile(Operation op, // op matters only when default_path is empty - const wxString& message, + const TranslatableString& message, const FilePath& default_path, const FilePath& default_filename, // empty, or one extension, or multiple extensions joined with diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index ce224e5e7..ebcf08216 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -1061,7 +1061,7 @@ void FrequencyPlotDialog::OnExport(wxCommandEvent & WXUNUSED(event)) wxString fName = _("spectrum.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Export Spectral Data As:"), + XO("Export Spectral Data As:"), wxEmptyString, fName, wxT("txt"), diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 01d3b2613..28b7f0b09 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -628,7 +628,7 @@ void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event)) // Ask user for a filename wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - _("Select a text file containing labels"), + XO("Select a text file containing labels"), wxEmptyString, // Path wxT(""), // Name wxT(".txt"), // Extension @@ -677,7 +677,7 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event)) wxString fName = mTrackNames[mTrackNames.size() - 1].AfterFirst(wxT('-')).Mid(1); fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Export Labels As:"), + XO("Export Labels As:"), wxEmptyString, fName, wxT("txt"), diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index 50296b13f..335fb9bf8 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -785,14 +785,14 @@ bool ProjectFileManager::SaveAs(bool bWantSaveCopy /*= false*/, bool bLossless / filename = FileNames::DefaultToDocumentsFolder(wxT("/SaveAs/Path")); } - wxString title; + TranslatableString title; wxString message; if (bWantSaveCopy) { if (bLossless) { - title = wxString::Format(_("%sSave Lossless Copy of Project \"%s\" As..."), - Restorer.sProjNumber,Restorer.sProjName); + title = XO("%sSave Lossless Copy of Project \"%s\" As...") + .Format( Restorer.sProjNumber,Restorer.sProjName ); message = _("\ 'Save Lossless Copy of Project' is for an Audacity project, not an audio file.\n\ For an audio file that will open in other apps, use 'Export'.\n\n\ @@ -802,8 +802,8 @@ with no loss of quality, but the projects are large.\n"); } else { - title = wxString::Format(_("%sSave Compressed Copy of Project \"%s\" As..."), - Restorer.sProjNumber,Restorer.sProjName); + title = XO("%sSave Compressed Copy of Project \"%s\" As...") + .Format( Restorer.sProjNumber, Restorer.sProjName ); message = _("\ 'Save Compressed Copy of Project' is for an Audacity project, not an audio file.\n\ For an audio file that will open in other apps, use 'Export'.\n\n\ @@ -814,8 +814,8 @@ but they have some loss of fidelity.\n"); } else { - title = wxString::Format(_("%sSave Project \"%s\" As..."), - Restorer.sProjNumber, Restorer.sProjName); + title = XO("%sSave Project \"%s\" As...") + .Format( Restorer.sProjNumber, Restorer.sProjName ); message = _("\ 'Save Project' is for an Audacity project, not an audio file.\n\ For an audio file that will open in other apps, use 'Export'.\n"); diff --git a/src/Tags.cpp b/src/Tags.cpp index e925e2547..95446adef 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -1244,7 +1244,7 @@ void TagsEditorDialog::OnLoad(wxCommandEvent & WXUNUSED(event)) // Ask the user for the real name fn = FileNames::SelectFile(FileNames::Operation::_None, - _("Load Metadata As:"), + XO("Load Metadata As:"), FileNames::DataDir(), wxT("Tags.xml"), wxT("xml"), @@ -1299,7 +1299,7 @@ void TagsEditorDialog::OnSave(wxCommandEvent & WXUNUSED(event)) // Ask the user for the real name fn = FileNames::SelectFile(FileNames::Operation::_None, - _("Save Metadata As:"), + XO("Save Metadata As:"), FileNames::DataDir(), wxT("Tags.xml"), wxT("xml"), diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 812c21388..b8bbadbd6 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -318,7 +318,7 @@ void TimerRecordDialog::OnTimeText_Duration(wxCommandEvent& WXUNUSED(event)) void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(event)) { wxString fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Save Timer Recording As"), + XO("Save Timer Recording As"), m_fnAutoSaveFile.GetPath(), m_fnAutoSaveFile.GetFullName(), wxT("aup"), diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 1eb3d0698..65bd53562 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -528,7 +528,7 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event)) wxString fName = wxT("contrast.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Export Contrast Result As:"), + XO("Export Contrast Result As:"), wxEmptyString, fName, wxT("txt"), diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 9a9bfd6d3..d3e774d55 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -1861,7 +1861,7 @@ void VSTEffect::ExportPresets() // Passing a valid parent will cause some effects dialogs to malfunction // upon returning from the FileNames::SelectFile(). path = FileNames::SelectFile(FileNames::Operation::_None, - _("Save VST Preset As:"), + XO("Save VST Preset As:"), FileNames::DataDir(), wxEmptyString, wxT("xml"), @@ -1913,7 +1913,7 @@ void VSTEffect::ImportPresets() // Ask the user for the real name path = FileNames::SelectFile(FileNames::Operation::_None, - _("Load VST Preset:"), + XO("Load VST Preset:"), FileNames::DataDir(), wxEmptyString, wxT("xml"), diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index ae33a71a0..f22a261d1 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -176,7 +176,7 @@ void ExportCLOptions::OnBrowse(wxCommandEvent& WXUNUSED(event)) #endif path = FileNames::SelectFile(FileNames::Operation::Open, - _("Find path to command"), + XO("Find path to command"), wxEmptyString, wxEmptyString, ext, diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index cf4c2c002..1fea99c0e 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -619,11 +619,10 @@ public: void OnBrowse(wxCommandEvent & WXUNUSED(event)) { - wxString question; /* i18n-hint: It's asking for the location of a file, for * example, "Where is lame_enc.dll?" - you could translate * "Where would I find the file %s" instead if you want. */ - question.Printf(_("Where is %s?"), mName); + auto question = XO("Where is %s?").Format( mName ); wxString path = FileNames::SelectFile(FileNames::Operation::_None, question, diff --git a/src/menus/FileMenus.cpp b/src/menus/FileMenus.cpp index 5cb94830d..10af6b9a0 100644 --- a/src/menus/FileMenus.cpp +++ b/src/menus/FileMenus.cpp @@ -229,7 +229,7 @@ void OnExportLabels(const CommandContext &context) fName = (*trackRange.rbegin())->GetName(); fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Export Labels As:"), + XO("Export Labels As:"), wxEmptyString, fName, wxT("txt"), @@ -315,7 +315,7 @@ void OnExportMIDI(const CommandContext &context) wxString fName; fName = FileNames::SelectFile(FileNames::Operation::Export, - _("Export MIDI As:"), + XO("Export MIDI As:"), wxEmptyString, fName, wxT(".mid|.gro"), @@ -419,7 +419,7 @@ void OnImportLabels(const CommandContext &context) wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - _("Select a text file containing labels"), + XO("Select a text file containing labels"), wxEmptyString, // Path wxT(""), // Name wxT(".txt"), // Extension @@ -463,7 +463,7 @@ void OnImportMIDI(const CommandContext &context) auto &window = GetProjectFrame( project ); wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - _("Select a MIDI file"), + XO("Select a MIDI file"), wxEmptyString, // Path wxT(""), // Name wxT(""), // Extension @@ -484,7 +484,7 @@ void OnImportRaw(const CommandContext &context) wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - _("Select any uncompressed audio file"), + XO("Select any uncompressed audio file"), wxEmptyString, // Path wxT(""), // Name wxT(""), // Extension diff --git a/src/menus/HelpMenus.cpp b/src/menus/HelpMenus.cpp index 4a2c62de8..fc0bad8e5 100644 --- a/src/menus/HelpMenus.cpp +++ b/src/menus/HelpMenus.cpp @@ -57,7 +57,7 @@ void ShowDiagnostics( if (dlg.ShowModal() == wxID_OK) { - const auto fileDialogTitle = XO("Save %s").Format( description ).Translation(); + const auto fileDialogTitle = XO("Save %s").Format( description ); wxString fName = FileNames::SelectFile(FileNames::Operation::Export, fileDialogTitle, wxEmptyString, @@ -72,7 +72,7 @@ void ShowDiagnostics( { AudacityMessageBox( XO("Unable to save %s").Format( description ).Translation(), - fileDialogTitle); + fileDialogTitle.Translation()); } } } diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 5ea9a2391..83328fce6 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -344,7 +344,7 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event)) wxString file = wxT("Audacity-keys.xml"); file = FileNames::SelectFile(FileNames::Operation::Open, - _("Select an XML file containing Audacity keyboard shortcuts..."), + XO("Select an XML file containing Audacity keyboard shortcuts..."), wxEmptyString, file, wxT(""), @@ -371,7 +371,7 @@ void KeyConfigPrefs::OnExport(wxCommandEvent & WXUNUSED(event)) wxString file = wxT("Audacity-keys.xml"); file = FileNames::SelectFile(FileNames::Operation::Export, - _("Export Keyboard Shortcuts As:"), + XO("Export Keyboard Shortcuts As:"), wxEmptyString, file, wxT("xml"),