1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 08:09:41 +02:00

TranslatableString in ProgressDialog

This commit is contained in:
Paul Licameli 2019-12-07 22:37:02 -05:00
parent 02cdb4ab45
commit 9a609fe1fe
30 changed files with 227 additions and 213 deletions

View File

@ -170,9 +170,9 @@ static void RemoveDependencies(AudacityProject *project,
auto &dirManager = DirManager::Get( *project );
const auto &settings = ProjectSettings::Get( *project );
ProgressDialog progress
(_("Removing Dependencies"),
_("Copying audio data into project..."));
ProgressDialog progress(
XO("Removing Dependencies"),
XO("Copying audio data into project..."));
auto updateResult = ProgressResult::Success;
// Hash aliasedFiles based on their full paths and

View File

@ -202,12 +202,12 @@ int DirManager::RecursivelyEnumerateWithProgress(const FilePath &dirPath,
wxString filespec,
bool bFiles, bool bDirs,
int progress_count,
const wxChar* message)
const TranslatableString &message)
{
Maybe<ProgressDialog> progress{};
if (message)
progress.create( _("Progress"), message );
if (!message.empty())
progress.create( XO("Progress"), message );
int count = RecursivelyEnumerate(
dirPath, filePathArray, dirspec,filespec,
@ -284,7 +284,7 @@ int DirManager::RecursivelyRemoveEmptyDirs(const FilePath &dirPath,
}
void DirManager::RecursivelyRemove(const FilePaths& filePathArray, int count, int bias,
int flags, const wxChar* message)
int flags, const TranslatableString &message)
{
bool bFiles= (flags & kCleanFiles) != 0;
bool bDirs = (flags & kCleanDirs) != 0;
@ -292,8 +292,8 @@ void DirManager::RecursivelyRemove(const FilePaths& filePathArray, int count, in
Maybe<ProgressDialog> progress{};
if (message)
progress.create( _("Progress"), message );
if (!message.empty())
progress.create( XO("Progress"), message );
auto nn = filePathArray.size();
for ( size_t ii = 0; ii < nn; ++ii ) {
@ -451,7 +451,7 @@ DirManager::~DirManager()
CleanTempDir();
//::wxRmdir(temp);
} else if( projFull.empty() && !mytemp.empty()) {
CleanDir(mytemp, wxEmptyString, ".DS_Store", _("Cleaning project temporary files"), kCleanTopDirToo | kCleanDirsOnlyIfEmpty );
CleanDir(mytemp, wxEmptyString, ".DS_Store", XO("Cleaning project temporary files"), kCleanTopDirToo | kCleanDirsOnlyIfEmpty );
}
}
@ -464,7 +464,7 @@ void DirManager::CleanTempDir()
{
// with default flags (none) this does not clean the top directory, and may remove non-empty
// directories.
CleanDir(globaltemp, wxT("project*"), wxEmptyString, _("Cleaning up temporary files"));
CleanDir(globaltemp, wxT("project*"), wxEmptyString, XO("Cleaning up temporary files"));
}
// static
@ -472,7 +472,7 @@ void DirManager::CleanDir(
const FilePath &path,
const wxString &dirSpec,
const wxString &fileSpec,
const wxString &msg,
const TranslatableString &msg,
int flags)
{
if (dontDeleteTempFiles)
@ -539,7 +539,7 @@ namespace {
fullPath,
wxEmptyString,
wxEmptyString,
_("Cleaning up after failed save"),
XO("Cleaning up after failed save"),
kCleanTopDirToo);
}
@ -687,8 +687,8 @@ DirManager::ProjectSetter::Impl::Impl(
{
/* i18n-hint: This title appears on a dialog that indicates the progress
in doing something.*/
ProgressDialog progress(_("Progress"),
_("Saving project data files"));
ProgressDialog progress(XO("Progress"),
XO("Saving project data files"));
int total = dirManager.mBlockFileHash.size();
@ -790,7 +790,7 @@ void DirManager::ProjectSetter::Impl::Commit()
wxEmptyString, // EmptyString => ALL directories.
// If the next line were wxEmptyString, ALL files would be removed.
".DS_Store", // Other project files should already have been removed.
_("Cleaning up cache directories"),
XO("Cleaning up cache directories"),
kCleanTopDirToo);
//This destroys the empty dirs of the OD block files, which are yet to come.
@ -1732,7 +1732,7 @@ void DirManager::RemoveOrphanBlockfiles()
wxEmptyString, // All files
true, false,
mBlockFileHash.size(), // rough guess of how many BlockFiles will be found/processed, for progress
_("Inspecting project file data"));
XO("Inspecting project file data"));
FilePaths orphanFilePathArray;
this->FindOrphanBlockFiles(
@ -1818,8 +1818,8 @@ void DirManager::WriteCacheToDisk()
if (numNeed == 0)
return;
ProgressDialog progress(_("Saving recorded audio"),
_("Saving recorded audio to disk"));
ProgressDialog progress(XO("Saving recorded audio"),
XO("Saving recorded audio to disk"));
iter = mBlockFileHash.begin();
int current = 0;

View File

@ -70,7 +70,7 @@ class PROFILE_DLL_API DirManager final
wxString filespec,
bool bFiles, bool bDirs,
int progress_count,
const wxChar* message);
const TranslatableString &message);
static int RecursivelyCountSubdirs( const FilePath &dirPath );
@ -79,7 +79,7 @@ class PROFILE_DLL_API DirManager final
ProgressDialog* pProgress = nullptr);
static void RecursivelyRemove(const FilePaths& filePathArray, int count, int bias,
int flags, const wxChar* message = nullptr);
int flags, const TranslatableString &message = {});
// Type of a function that builds a block file, using attributes from XML
using BlockFileDeserializer =
@ -193,7 +193,7 @@ class PROFILE_DLL_API DirManager final
const FilePath &path,
const wxString &dirSpec,
const wxString &fileSpec,
const wxString &msg,
const TranslatableString &msg,
int flags = 0);
void FindMissingAliasFiles(

View File

@ -156,8 +156,8 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
auto updateResult = ProgressResult::Success;
{
ProgressDialog progress(_("Mix and Render"),
_("Mixing and rendering tracks"));
ProgressDialog progress(XO("Mix and Render"),
XO("Mixing and rendering tracks"));
while (updateResult == ProgressResult::Success) {
auto blockLen = mixer.Process(maxBlockLen);

View File

@ -982,15 +982,14 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
mLongestPath + wxT("\n") +
mLongestPath + wxT("\n");
wxString msg;
msg.Printf(_("Enabling effects or commands:\n\n%s"), last3);
auto msg = XO("Enabling effects or commands:\n\n%s").Format( last3 );
// Make sure the progress dialog is deleted before we call EndModal() or
// we will leave the project window in an unusable state on OSX.
// See bug #1192.
{
ProgressDialog progress(GetTitle(), msg, pdlgHideStopButton);
ProgressDialog progress(
TranslatableString{ GetTitle() }, msg, pdlgHideStopButton);
progress.CenterOnParent();
int i = 0;
@ -1002,7 +1001,8 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
{
last3 = last3.AfterFirst(wxT('\n')) + item.path + wxT("\n");
auto status = progress.Update(++i, enableCount, wxString::Format(_("Enabling effect or command:\n\n%s"), last3));
auto status = progress.Update(++i, enableCount,
XO("Enabling effect or command:\n\n%s").Format( last3 ));
if (status == ProgressResult::Cancelled)
{
break;

View File

@ -77,7 +77,7 @@ int ProjectFSCK(
wxEmptyString, // All files
true, false,
dm.NumBlockFiles(), // rough guess of how many BlockFiles will be found/processed, for progress
_("Inspecting project file data"));
XO("Inspecting project file data"));
//
// MISSING ALIASED AUDIO FILES
@ -360,9 +360,9 @@ other projects. \
if ((nResult != FSCKstatus_CLOSE_REQ) && !ODManager::HasLoadedODFlag())
{
// Remove any empty directories.
ProgressDialog pProgress
(_("Progress"),
_("Cleaning up unused directories in project data"));
ProgressDialog pProgress(
XO("Progress"),
XO("Cleaning up unused directories in project data"));
// nDirCount is for updating pProgress. +1 because we may DELETE dirPath.
int nDirCount = DirManager::RecursivelyCountSubdirs(dirPath) + 1;
DirManager::RecursivelyRemoveEmptyDirs(dirPath, nDirCount, &pProgress);

View File

@ -546,33 +546,34 @@ int TimerRecordDialog::RunWaitDialog()
ProjectAudioManager::Get( *pProject ).OnRecord(false);
bool bIsRecording = true;
wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());
auto sPostAction = TranslatableString{
m_pTimerAfterCompleteChoiceCtrl->GetStringSelection() };
// Two column layout.
TimerProgressDialog::MessageTable columns{
{
_("Recording start:") ,
_("Duration:") ,
_("Recording end:") ,
XO("Recording start:") ,
XO("Duration:") ,
XO("Recording end:") ,
{} ,
_("Automatic Save enabled:") ,
_("Automatic Export enabled:") ,
_("Action after Timer Recording:") ,
XO("Automatic Save enabled:") ,
XO("Automatic Export enabled:") ,
XO("Action after Timer Recording:") ,
},
{
GetDisplayDate(m_DateTime_Start) ,
m_TimeSpan_Duration.Format() ,
TranslatableString{ m_TimeSpan_Duration.Format() },
GetDisplayDate(m_DateTime_End) ,
{} ,
(m_bAutoSaveEnabled ? _("Yes") : _("No")) ,
(m_bAutoExportEnabled ? _("Yes") : _("No")) ,
(m_bAutoSaveEnabled ? XO("Yes") : XO("No")) ,
(m_bAutoExportEnabled ? XO("Yes") : XO("No")) ,
sPostAction ,
}
};
TimerProgressDialog
progress(m_TimeSpan_Duration.GetMilliseconds().GetValue(),
_("Audacity Timer Record Progress"),
XO("Audacity Timer Record Progress"),
columns,
pdlgHideCancelButton | pdlgConfirmStopCancel);
@ -743,7 +744,7 @@ int TimerRecordDialog::ExecutePostRecordActions(bool bWasStopped) {
return iPostRecordAction;
}
wxString TimerRecordDialog::GetDisplayDate( wxDateTime & dt )
TranslatableString TimerRecordDialog::GetDisplayDate( wxDateTime & dt )
{
#if defined(__WXMSW__)
// On Windows, wxWidgets uses the system date control and it displays the
@ -789,7 +790,7 @@ wxString TimerRecordDialog::GetDisplayDate( wxDateTime & dt )
// Use default formatting
wxPrintf(wxT("%s\n"), dt.Format());
return dt.FormatDate() + wxT(" ") + dt.FormatTime();
return TranslatableString{ dt.FormatDate() + wxT(" ") + dt.FormatTime() };
}
TimerRecordPathCtrl * TimerRecordDialog::NewPathControl(wxWindow *wParent, const int iID,
@ -1057,26 +1058,27 @@ void TimerRecordDialog::UpdateEnd()
ProgressResult TimerRecordDialog::WaitForStart()
{
// MY: The Waiting For Start dialog now shows what actions will occur after recording has completed
wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());
auto sPostAction = TranslatableString{
m_pTimerAfterCompleteChoiceCtrl->GetStringSelection() };
// Two column layout.
TimerProgressDialog::MessageTable columns{
{
_("Waiting to start recording at:") ,
_("Recording duration:") ,
_("Scheduled to stop at:") ,
XO("Waiting to start recording at:") ,
XO("Recording duration:") ,
XO("Scheduled to stop at:") ,
{} ,
_("Automatic Save enabled:") ,
_("Automatic Export enabled:") ,
_("Action after Timer Recording:") ,
XO("Automatic Save enabled:") ,
XO("Automatic Export enabled:") ,
XO("Action after Timer Recording:") ,
},
{
GetDisplayDate(m_DateTime_Start) ,
m_TimeSpan_Duration.Format() ,
GetDisplayDate(m_DateTime_Start),
TranslatableString{ m_TimeSpan_Duration.Format() },
GetDisplayDate(m_DateTime_End) ,
{} ,
(m_bAutoSaveEnabled ? _("Yes") : _("No")) ,
(m_bAutoExportEnabled ? _("Yes") : _("No")) ,
(m_bAutoSaveEnabled ? XO("Yes") : XO("No")) ,
(m_bAutoExportEnabled ? XO("Yes") : XO("No")) ,
sPostAction ,
},
};
@ -1084,12 +1086,12 @@ ProgressResult TimerRecordDialog::WaitForStart()
wxDateTime startWait_DateTime = wxDateTime::UNow();
wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime;
TimerProgressDialog progress(waitDuration.GetMilliseconds().GetValue(),
_("Audacity Timer Record - Waiting for Start"),
XO("Audacity Timer Record - Waiting for Start"),
columns,
pdlgHideStopButton | pdlgConfirmStopCancel | pdlgHideElapsedTime,
/* i18n-hint: "in" means after a duration of time,
which is shown below this string */
_("Recording will commence in:"));
XO("Recording will commence in:"));
auto updateResult = ProgressResult::Success;
bool bIsRecording = false;
@ -1104,27 +1106,28 @@ ProgressResult TimerRecordDialog::WaitForStart()
ProgressResult TimerRecordDialog::PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions)
{
wxString sAction = m_pTimerAfterCompleteChoiceCtrl->GetString(iActionIndex);
wxString sCountdownLabel;
auto sAction = TranslatableString{ m_pTimerAfterCompleteChoiceCtrl
->GetString(iActionIndex) };
/* i18n-hint: %s is one of "Do nothing", "Exit Audacity", "Restart system",
or "Shutdown system", and
"in" means after a duration of time, shown below this string */
sCountdownLabel.Printf(_("%s in:"), sAction);
auto sCountdownLabel = XO("%s in:").Format( sAction );
// Two column layout.
TimerProgressDialog::MessageTable columns{
{
_("Timer Recording completed.") ,
XO("Timer Recording completed.") ,
{} ,
_("Recording Saved:") ,
_("Recording Exported:") ,
_("Action after Timer Recording:") ,
XO("Recording Saved:") ,
XO("Recording Exported:") ,
XO("Action after Timer Recording:") ,
},
{
{} ,
{} ,
((eCompletedActions & TR_ACTION_SAVED) ? _("Yes") : _("No")) ,
((eCompletedActions & TR_ACTION_EXPORTED) ? _("Yes") : _("No")) ,
((eCompletedActions & TR_ACTION_SAVED) ? XO("Yes") : XO("No")) ,
((eCompletedActions & TR_ACTION_EXPORTED) ? XO("Yes") : XO("No")) ,
sAction ,
},
};
@ -1135,7 +1138,7 @@ ProgressResult TimerRecordDialog::PreActionDelay(int iActionIndex, TimerRecordCo
wxDateTime dtActionTime = dtNow.Add(tsWait);
TimerProgressDialog dlgAction(tsWait.GetMilliseconds().GetValue(),
_("Audacity Timer Record - Waiting"),
XO("Audacity Timer Record - Waiting"),
columns,
pdlgHideStopButton | pdlgHideElapsedTime,
sCountdownLabel);

View File

@ -78,7 +78,7 @@ private:
void OnOK(wxCommandEvent& event);
void OnHelpButtonClick(wxCommandEvent& event);
wxString GetDisplayDate(wxDateTime & dt);
TranslatableString GetDisplayDate(wxDateTime & dt);
void PopulateOrExchange(ShuttleGui& S);
bool TransferDataFromWindow() override;

View File

@ -208,10 +208,10 @@ bool AudacityCommand::DoAudacityCommand(wxWindow *parent,
bool skipFlag = CheckWhetherSkipAudacityCommand();
if (skipFlag == false)
{
auto name = GetTranslatedName();
auto name = GetUntranslatedName();
ProgressDialog progress{
name,
wxString::Format(_("Applying %s..."), name),
XO("Applying %s...").Format( name ),
pdlgHideStopButton
};
auto vr = valueRestorer( mProgress, &progress );

View File

@ -1267,10 +1267,10 @@ bool Effect::DoEffect(wxWindow *parent,
bool skipFlag = CheckWhetherSkipEffect();
if (skipFlag == false)
{
auto name = GetTranslatedName();
auto name = GetUntranslatedName();
ProgressDialog progress{
name,
wxString::Format(_("Applying %s..."), name),
XO("Applying %s...").Format( name ),
pdlgHideStopButton
};
auto vr = valueRestorer( mProgress, &progress );
@ -1996,7 +1996,7 @@ void Effect::IncludeNotSelectedPreviewTracks(bool includeNotSelected)
mPreviewWithNotSelected = includeNotSelected;
}
bool Effect::TotalProgress(double frac, const wxString &msg)
bool Effect::TotalProgress(double frac, const TranslatableString &msg)
{
auto updateResult = (mProgress ?
mProgress->Update(frac, msg) :
@ -2004,7 +2004,7 @@ bool Effect::TotalProgress(double frac, const wxString &msg)
return (updateResult != ProgressResult::Success);
}
bool Effect::TrackProgress(int whichTrack, double frac, const wxString &msg)
bool Effect::TrackProgress(int whichTrack, double frac, const TranslatableString &msg)
{
auto updateResult = (mProgress ?
mProgress->Update(whichTrack + frac, (double) mNumTracks, msg) :
@ -2012,7 +2012,7 @@ bool Effect::TrackProgress(int whichTrack, double frac, const wxString &msg)
return (updateResult != ProgressResult::Success);
}
bool Effect::TrackGroupProgress(int whichGroup, double frac, const wxString &msg)
bool Effect::TrackGroupProgress(int whichGroup, double frac, const TranslatableString &msg)
{
auto updateResult = (mProgress ?
mProgress->Update(whichGroup + frac, (double) mNumGroups, msg) :
@ -2398,8 +2398,8 @@ void Effect::Preview(bool dryOnly)
// Apply effect
if (!dryOnly) {
ProgressDialog progress{
GetTranslatedName(),
_("Preparing preview"),
GetUntranslatedName(),
XO("Preparing preview"),
pdlgHideCancelButton
}; // Have only "Stop" button.
auto vr = valueRestorer( mProgress, &progress );
@ -2429,7 +2429,7 @@ void Effect::Preview(bool dryOnly)
// The progress dialog blocks these events.
{
ProgressDialog progress
(GetTranslatedName(), _("Previewing"), pdlgHideCancelButton);
(GetUntranslatedName(), XO("Previewing"), pdlgHideCancelButton);
while (gAudioIO->IsStreamActive(token) && previewing == ProgressResult::Success) {
::wxMilliSleep(100);

View File

@ -335,15 +335,15 @@ protected:
// is okay, but don't try to undo).
// Pass a fraction between 0.0 and 1.0
bool TotalProgress(double frac, const wxString & = {});
bool TotalProgress(double frac, const TranslatableString & = {});
// Pass a fraction between 0.0 and 1.0, for the current track
// (when doing one track at a time)
bool TrackProgress(int whichTrack, double frac, const wxString & = {});
bool TrackProgress(int whichTrack, double frac, const TranslatableString & = {});
// Pass a fraction between 0.0 and 1.0, for the current track group
// (when doing stereo groups at a time)
bool TrackGroupProgress(int whichGroup, double frac, const wxString & = {});
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString & = {});
int GetNumWaveTracks() { return mNumTracks; }
int GetNumWaveGroups() { return mNumGroups; }

View File

@ -174,7 +174,7 @@ bool EffectLoudness::Process()
// Iterate over each track
this->CopyInputTracks(); // Set up mOutputTracks.
bool bGoodResult = true;
wxString topMsg = _("Normalizing Loudness...\n");
auto topMsg = XO("Normalizing Loudness...\n");
AllocBuffers();
mProgressVal = 0;
@ -200,7 +200,7 @@ bool EffectLoudness::Process()
mSteps = 2;
mProgressMsg =
topMsg + wxString::Format(_("Analyzing: %s"), trackName);
topMsg + XO("Analyzing: %s").Format( trackName );
auto range = mStereoInd
? TrackList::SingletonRange(track)
@ -258,7 +258,7 @@ bool EffectLoudness::Process()
mMult = sqrt(mMult);
}
mProgressMsg = topMsg + wxString::Format(_("Processing: %s"), trackName);
mProgressMsg = topMsg + XO("Processing: %s").Format( trackName );
if(!ProcessOne(range, false))
{
// Processing failed -> abort
@ -394,7 +394,7 @@ bool EffectLoudness::GetTrackRMS(WaveTrack* track, float& rms)
while (ProjectFileManager::GetODFlags(*track)) {
// update the gui
if (ProgressResult::Cancelled == mProgress->Update(
0, _("Waiting for waveform to finish computing...")) )
0, XO("Waiting for waveform to finish computing...")) )
return false;
wxMilliSleep(100);
}

View File

@ -87,7 +87,7 @@ private:
double mCurT1;
double mProgressVal;
int mSteps;
wxString mProgressMsg;
TranslatableString mProgressMsg;
double mTrackLen;
double mCurRate;

View File

@ -181,15 +181,15 @@ bool EffectNormalize::Process()
this->CopyInputTracks(); // Set up mOutputTracks.
bool bGoodResult = true;
double progress = 0;
wxString topMsg;
TranslatableString topMsg;
if(mDC && mGain)
topMsg = _("Removing DC offset and Normalizing...\n");
topMsg = XO("Removing DC offset and Normalizing...\n");
else if(mDC && !mGain)
topMsg = _("Removing DC offset...\n");
topMsg = XO("Removing DC offset...\n");
else if(!mDC && mGain)
topMsg = _("Normalizing without removing DC offset...\n");
topMsg = XO("Normalizing without removing DC offset...\n");
else if(!mDC && !mGain)
topMsg = _("Not doing anything...\n"); // shouldn't get here
topMsg = XO("Not doing anything...\n"); // shouldn't get here
for ( auto track : mOutputTracks->Selected< WaveTrack >()
+ ( mStereoInd ? &Track::Any : &Track::IsLeader ) ) {
@ -216,15 +216,13 @@ bool EffectNormalize::Process()
extent = std::numeric_limits<float>::lowest();
std::vector<float> offsets;
wxString msg;
if (range.size() == 1)
auto msg = (range.size() == 1)
// mono or 'stereo tracks independently'
msg = topMsg +
wxString::Format( _("Analyzing: %s"), trackName );
else
msg = topMsg +
? topMsg +
XO("Analyzing: %s").Format( trackName )
: topMsg +
// TODO: more-than-two-channels-message
wxString::Format( _("Analyzing first track of stereo pair: %s"), trackName);
XO("Analyzing first track of stereo pair: %s").Format( trackName );
// Analysis loop over channels collects offsets and extent
for (auto channel : range) {
@ -238,7 +236,7 @@ bool EffectNormalize::Process()
offsets.push_back(offset);
// TODO: more-than-two-channels-message
msg = topMsg +
wxString::Format( _("Analyzing second track of stereo pair: %s"), trackName );
XO("Analyzing second track of stereo pair: %s").Format( trackName );
}
// Compute the multiplier using extent
@ -252,17 +250,17 @@ bool EffectNormalize::Process()
if (TrackList::Channels(track).size() == 1)
// really mono
msg = topMsg +
wxString::Format( _("Processing: %s"), trackName );
XO("Processing: %s").Format( trackName );
else
//'stereo tracks independently'
// TODO: more-than-two-channels-message
msg = topMsg +
wxString::Format( _("Processing stereo channels independently: %s"), trackName);
XO("Processing stereo channels independently: %s").Format( trackName );
}
else
msg = topMsg +
// TODO: more-than-two-channels-message
wxString::Format( _("Processing first track of stereo pair: %s"), trackName);
XO("Processing first track of stereo pair: %s").Format( trackName );
// Use multiplier in the second, processing loop over channels
auto pOffset = offsets.begin();
@ -272,7 +270,7 @@ bool EffectNormalize::Process()
goto break2;
// TODO: more-than-two-channels-message
msg = topMsg +
wxString::Format( _("Processing second track of stereo pair: %s"), trackName);
XO("Processing second track of stereo pair: %s").Format( trackName );
}
}
}
@ -359,7 +357,7 @@ bool EffectNormalize::TransferDataFromWindow()
// EffectNormalize implementation
bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const wxString &msg,
bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const TranslatableString &msg,
double &progress, float &offset, float &extent)
{
bool result = true;
@ -373,7 +371,7 @@ bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const wxString &msg,
while (ProjectFileManager::GetODFlags( *track )) {
// update the gui
if (ProgressResult::Cancelled == mProgress->Update(
0, _("Waiting for waveform to finish computing...")) )
0, XO("Waiting for waveform to finish computing...")) )
return false;
wxMilliSleep(100);
}
@ -409,7 +407,7 @@ bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const wxString &msg,
//AnalyseTrackData() takes a track, transforms it to bunch of buffer-blocks,
//and executes selected AnalyseOperation on it...
bool EffectNormalize::AnalyseTrackData(const WaveTrack * track, const wxString &msg,
bool EffectNormalize::AnalyseTrackData(const WaveTrack * track, const TranslatableString &msg,
double &progress, AnalyseOperation op, float &offset)
{
bool rc = true;
@ -477,7 +475,7 @@ bool EffectNormalize::AnalyseTrackData(const WaveTrack * track, const wxString &
// uses mMult and offset to normalize a track.
// mMult must be set before this is called
bool EffectNormalize::ProcessOne(
WaveTrack * track, const wxString &msg, double &progress, float offset)
WaveTrack * track, const TranslatableString &msg, double &progress, float offset)
{
bool rc = true;

View File

@ -64,10 +64,10 @@ private:
};
bool ProcessOne(
WaveTrack * t, const wxString &msg, double& progress, float offset);
bool AnalyseTrack(const WaveTrack * track, const wxString &msg,
WaveTrack * t, const TranslatableString &msg, double& progress, float offset);
bool AnalyseTrack(const WaveTrack * track, const TranslatableString &msg,
double &progress, float &offset, float &extent);
bool AnalyseTrackData(const WaveTrack * track, const wxString &msg, double &progress,
bool AnalyseTrackData(const WaveTrack * track, const TranslatableString &msg, double &progress,
AnalyseOperation op, float &offset);
void AnalyseDataDC(float *buffer, size_t len);
void ProcessData(float *buffer, size_t len, float offset);

View File

@ -1347,10 +1347,10 @@ bool NyquistEffect::ProcessOne()
// so notify the user that process has completed (bug 558)
if ((rval != nyx_audio) && ((mCount + mCurNumChannels) == mNumSelectedChannels)) {
if (mCurNumChannels == 1) {
TrackProgress(mCount, 1.0, _("Processing complete."));
TrackProgress(mCount, 1.0, XO("Processing complete."));
}
else {
TrackGroupProgress(mCount, 1.0, _("Processing complete."));
TrackGroupProgress(mCount, 1.0, XO("Processing complete."));
}
}

View File

@ -271,7 +271,7 @@ std::unique_ptr<Mixer> ExportPlugin::CreateMixer(const TrackList &tracks,
}
void ExportPlugin::InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
const wxString &title, const wxString &message)
const TranslatableString &title, const TranslatableString &message)
{
if (!pDialog)
pDialog = std::make_unique<ProgressDialog>( title, message );
@ -283,9 +283,10 @@ void ExportPlugin::InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
}
void ExportPlugin::InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
const wxFileNameWrapper &title, const wxString &message)
const wxFileNameWrapper &title, const TranslatableString &message)
{
return InitProgress( pDialog, title.GetName(), message );
return InitProgress(
pDialog, TranslatableString{ title.GetName() }, message );
}
//----------------------------------------------------------------------------

View File

@ -144,9 +144,9 @@ protected:
// Create or recycle a dialog.
static void InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
const wxString &title, const wxString &message);
const TranslatableString &title, const TranslatableString &message);
static void InitProgress(std::unique_ptr<ProgressDialog> &pDialog,
const wxFileNameWrapper &title, const wxString &message);
const wxFileNameWrapper &title, const TranslatableString &message);
private:
std::vector<FormatInfo> mFormatInfos;

View File

@ -462,10 +462,10 @@ ProgressResult ExportCL::Export(AudacityProject *project,
} );
// Prepare the progress display
InitProgress( pDialog, _("Export"),
InitProgress( pDialog, XO("Export"),
selectionOnly
? _("Exporting the selected audio using command-line encoder")
: _("Exporting the audio using command-line encoder") );
? XO("Exporting the selected audio using command-line encoder")
: XO("Exporting the audio using command-line encoder") );
auto &progress = *pDialog;
// Start piping the mixed data to the command

View File

@ -912,10 +912,10 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project,
{
InitProgress( pDialog, fName,
selectionOnly
? wxString::Format(_("Exporting selected audio as %s"),
ExportFFmpegOptions::fmts[mSubFormat].description.Translation())
: wxString::Format(_("Exporting the audio as %s"),
ExportFFmpegOptions::fmts[mSubFormat].description.Translation()) );
? XO("Exporting selected audio as %s")
.Format( ExportFFmpegOptions::fmts[mSubFormat].description )
: XO("Exporting the audio as %s")
.Format( ExportFFmpegOptions::fmts[mSubFormat].description ) );
auto &progress = *pDialog;
while (updateResult == ProgressResult::Success) {

View File

@ -381,8 +381,8 @@ ProgressResult ExportFLAC::Export(AudacityProject *project,
InitProgress( pDialog, fName,
selectionOnly
? _("Exporting the selected audio as FLAC")
: _("Exporting the audio as FLAC") );
? XO("Exporting the selected audio as FLAC")
: XO("Exporting the audio as FLAC") );
auto &progress = *pDialog;
while (updateResult == ProgressResult::Success) {

View File

@ -309,10 +309,10 @@ ProgressResult ExportMP2::Export(AudacityProject *project,
InitProgress( pDialog, fName,
selectionOnly
? wxString::Format(_("Exporting selected audio at %ld kbps"),
bitrate)
: wxString::Format(_("Exporting the audio at %ld kbps"),
bitrate) );
? XO("Exporting selected audio at %ld kbps")
.Format( bitrate )
: XO("Exporting the audio at %ld kbps")
.Format( bitrate ) );
auto &progress = *pDialog;
while (updateResult == ProgressResult::Success) {

View File

@ -1879,24 +1879,24 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
channels, inSamples, true,
rate, int16Sample, true, mixerSpec);
wxString title;
TranslatableString title;
if (rmode == MODE_SET) {
title.Printf(selectionOnly ?
_("Exporting selected audio with %s preset") :
_("Exporting the audio with %s preset"),
setRateNamesShort[brate].Translation());
title = (selectionOnly ?
XO("Exporting selected audio with %s preset") :
XO("Exporting the audio with %s preset"))
.Format( setRateNamesShort[brate] );
}
else if (rmode == MODE_VBR) {
title.Printf(selectionOnly ?
_("Exporting selected audio with VBR quality %s") :
_("Exporting the audio with VBR quality %s"),
varRateNames[brate].Translation());
title = (selectionOnly ?
XO("Exporting selected audio with VBR quality %s") :
XO("Exporting the audio with VBR quality %s"))
.Format( varRateNames[brate] );
}
else {
title.Printf(selectionOnly ?
_("Exporting selected audio at %d Kbps") :
_("Exporting the audio at %d Kbps"),
brate);
title = (selectionOnly ?
XO("Exporting selected audio at %d Kbps") :
XO("Exporting the audio at %d Kbps"))
.Format( brate );
}
InitProgress( pDialog, fName, title );

View File

@ -283,8 +283,8 @@ ProgressResult ExportOGG::Export(AudacityProject *project,
InitProgress( pDialog, fName,
selectionOnly
? _("Exporting the selected audio as Ogg Vorbis")
: _("Exporting the audio as Ogg Vorbis") );
? XO("Exporting the selected audio as Ogg Vorbis")
: XO("Exporting the audio as Ogg Vorbis") );
auto &progress = *pDialog;
while (updateResult == ProgressResult::Success && !eos) {

View File

@ -554,11 +554,10 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
rate, format, true, mixerSpec);
InitProgress( pDialog, fName,
selectionOnly
? wxString::Format(_("Exporting the selected audio as %s"),
formatStr)
: wxString::Format(_("Exporting the audio as %s"),
formatStr) );
(selectionOnly
? XO("Exporting the selected audio as %s")
: XO("Exporting the audio as %s"))
.Format( formatStr ) );
auto &progress = *pDialog;
while (updateResult == ProgressResult::Success) {

View File

@ -806,7 +806,8 @@ void ImportFileHandle::CreateProgress()
{
wxFileName ff( mFilename );
auto title = XO("Importing %s").Format( GetFileDescription() ).Translation();
mProgress = std::make_unique< ProgressDialog >( title, ff.GetFullName() );
auto title = XO("Importing %s").Format( GetFileDescription() );
mProgress = std::make_unique< ProgressDialog >(
title, TranslatableString{ ff.GetFullName() } );
}

View File

@ -218,12 +218,10 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
totalFrames = 0;
}
wxString msg;
msg.Printf(_("Importing %s"), wxFileName::FileName(fileName).GetFullName());
auto msg = XO("Importing %s").Format( wxFileName::FileName(fileName).GetFullName() );
/* i18n-hint: 'Raw' means 'unprocessed' here and should usually be tanslated.*/
ProgressDialog progress(_("Import Raw"), msg);
ProgressDialog progress(XO("Import Raw"), msg);
size_t block;
do {

View File

@ -762,11 +762,9 @@ void OnResample(const CommandContext &context)
auto flags = UndoPush::AUTOSAVE;
for (auto wt : tracks.Selected< WaveTrack >())
{
wxString msg;
auto msg = XO("Resampling track %d").Format( ++ndx );
msg.Printf(_("Resampling track %d"), ++ndx);
ProgressDialog progress(_("Resample"), msg);
ProgressDialog progress(XO("Resample"), msg);
// The resampling of a track may be stopped by the user. This might
// leave a track with multiple clips in a partially resampled state.

View File

@ -998,19 +998,19 @@ ProgressDialog::ProgressDialog()
{
}
ProgressDialog::ProgressDialog(const wxString & title,
const wxString & message /* = {}*/,
ProgressDialog::ProgressDialog(const TranslatableString & title,
const TranslatableString & message /* = {}*/,
int flags /* = pdlgDefaultFlags */,
const wxString & sRemainingLabelText /* = {} */)
const TranslatableString & sRemainingLabelText /* = {} */)
: wxDialogWrapper()
{
Create(title, message, flags, sRemainingLabelText);
}
ProgressDialog::ProgressDialog(const wxString & title,
ProgressDialog::ProgressDialog(const TranslatableString & title,
const MessageTable &columns,
int flags /* = pdlgDefaultFlags */,
const wxString & sRemainingLabelText /* = {} */)
const TranslatableString & sRemainingLabelText /* = {} */)
: wxDialogWrapper()
{
Create(title, columns, flags, sRemainingLabelText);
@ -1110,16 +1110,17 @@ void ProgressDialog::AddMessageAsColumn(wxBoxSizer * pSizer,
// Join strings
auto sText = column[0];
std::for_each( column.begin() + 1, column.end(),
[&](const wxString &text) { sText += wxT("\n") + text; });
[&](const TranslatableString &text)
{ sText.Join( text, wxT("\n") ); });
// Create a statictext object and add to the sizer
wxStaticText* oText = safenew wxStaticText(this,
wxID_ANY,
sText,
sText.Translation(),
wxDefaultPosition,
wxDefaultSize,
wxALIGN_LEFT);
oText->SetName(sText); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
oText->SetName(sText.Translation()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
// If this is the first column then set the mMessage pointer so non-TimerRecord usages
// will still work correctly in SetMessage()
@ -1130,10 +1131,10 @@ void ProgressDialog::AddMessageAsColumn(wxBoxSizer * pSizer,
pSizer->Add(oText, 1, wxEXPAND | wxALL, 5);
}
bool ProgressDialog::Create(const wxString & title,
const wxString & message /* = {} */,
bool ProgressDialog::Create(const TranslatableString & title,
const TranslatableString & message /* = {} */,
int flags /* = pdlgDefaultFlags */,
const wxString & sRemainingLabelText /* = {} */)
const TranslatableString & sRemainingLabelText /* = {} */)
{
MessageTable columns(1);
columns.back().push_back(message);
@ -1143,16 +1144,16 @@ bool ProgressDialog::Create(const wxString & title,
// Record some values used in case of change of message
// TODO: make the following work in case of message tables
wxClientDC dc(this);
dc.GetMultiLineTextExtent(message, &mLastW, &mLastH);
dc.GetMultiLineTextExtent(message.Translation(), &mLastW, &mLastH);
}
return result;
}
bool ProgressDialog::Create(const wxString & title,
bool ProgressDialog::Create(const TranslatableString & title,
const MessageTable & columns,
int flags /* = pdlgDefaultFlags */,
const wxString & sRemainingLabelText /* = {} */)
const TranslatableString & sRemainingLabelText /* = {} */)
{
Init();
@ -1165,7 +1166,7 @@ bool ProgressDialog::Create(const wxString & title,
bool success = wxDialogWrapper::Create(parent,
wxID_ANY,
title,
title.Translation(),
wxDefaultPosition,
wxDefaultSize,
wxDEFAULT_DIALOG_STYLE |
@ -1238,14 +1239,14 @@ bool ProgressDialog::Create(const wxString & title,
}
// Customised "Remaining" label text
wxString sRemainingText = sRemainingLabelText;
auto sRemainingText = sRemainingLabelText;
if (sRemainingText.empty()) {
sRemainingText = _("Remaining Time:");
sRemainingText = XO("Remaining Time:");
}
window = safenew wxStaticText(this,
wxID_ANY,
sRemainingText,
sRemainingText.Translation(),
wxDefaultPosition,
wxDefaultSize,
wxALIGN_RIGHT);
@ -1313,7 +1314,8 @@ bool ProgressDialog::Create(const wxString & title,
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(int value, const wxString & message)
ProgressResult ProgressDialog::Update(
int value, const TranslatableString & message)
{
if (mCancel)
{
@ -1406,7 +1408,8 @@ ProgressResult ProgressDialog::Update(int value, const wxString & message)
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(double current, const wxString & message)
ProgressResult ProgressDialog::Update(
double current, const TranslatableString & message)
{
return Update((int)(current * 1000), message);
}
@ -1414,7 +1417,8 @@ ProgressResult ProgressDialog::Update(double current, const wxString & message)
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(wxULongLong_t current, wxULongLong_t total, const wxString & message)
ProgressResult ProgressDialog::Update(
wxULongLong_t current, wxULongLong_t total, const TranslatableString & message)
{
if (total != 0)
{
@ -1429,7 +1433,8 @@ ProgressResult ProgressDialog::Update(wxULongLong_t current, wxULongLong_t total
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(wxLongLong current, wxLongLong total, const wxString & message)
ProgressResult ProgressDialog::Update(
wxLongLong current, wxLongLong total, const TranslatableString & message)
{
if (total.GetValue() != 0)
{
@ -1444,7 +1449,8 @@ ProgressResult ProgressDialog::Update(wxLongLong current, wxLongLong total, cons
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(wxLongLong_t current, wxLongLong_t total, const wxString & message)
ProgressResult ProgressDialog::Update(
wxLongLong_t current, wxLongLong_t total, const TranslatableString & message)
{
if (total != 0)
{
@ -1459,7 +1465,8 @@ ProgressResult ProgressDialog::Update(wxLongLong_t current, wxLongLong_t total,
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(int current, int total, const wxString & message)
ProgressResult ProgressDialog::Update(
int current, int total, const TranslatableString & message)
{
if (total != 0)
{
@ -1474,7 +1481,8 @@ ProgressResult ProgressDialog::Update(int current, int total, const wxString & m
//
// Update the time and, optionally, the message
//
ProgressResult ProgressDialog::Update(double current, double total, const wxString & message)
ProgressResult ProgressDialog::Update(
double current, double total, const TranslatableString & message)
{
if (total != 0)
{
@ -1489,15 +1497,15 @@ ProgressResult ProgressDialog::Update(double current, double total, const wxStri
//
// Update the message text
//
void ProgressDialog::SetMessage(const wxString & message)
void ProgressDialog::SetMessage(const TranslatableString & message)
{
if (!message.empty())
{
mMessage->SetLabel(message);
mMessage->SetLabel(message.Translation());
int w, h;
wxClientDC dc(mMessage);
dc.GetMultiLineTextExtent(message, &w, &h);
dc.GetMultiLineTextExtent(message.Translation(), &w, &h);
bool sizeUpdated = false;
wxSize ds = GetClientSize();
@ -1532,6 +1540,11 @@ void ProgressDialog::SetMessage(const wxString & message)
}
}
void ProgressDialog::SetTitle(const TranslatableString & message)
{
wxDialogWrapper::SetTitle( message.Translation() );
}
//
// Recursivaly search the window list for the given window.
//
@ -1634,10 +1647,10 @@ bool ProgressDialog::ConfirmAction(const wxString & sPrompt,
}
TimerProgressDialog::TimerProgressDialog(const wxLongLong_t duration,
const wxString & title,
const TranslatableString & title,
const MessageTable & columns,
int flags /* = pdlgDefaultFlags */,
const wxString & sRemainingLabelText /* = {} */)
const TranslatableString & sRemainingLabelText /* = {} */)
: ProgressDialog(title, columns, flags, sRemainingLabelText)
{
mDuration = duration;

View File

@ -58,12 +58,12 @@ public:
ProgressDialog();
// Display a simple message.
ProgressDialog(const wxString & title,
const wxString & message = {},
ProgressDialog(const TranslatableString & title,
const TranslatableString & message = {},
int flags = pdlgDefaultFlags,
const wxString & sRemainingLabelText = {});
const TranslatableString & sRemainingLabelText = {});
using MessageColumn = std::vector< wxString >;
using MessageColumn = std::vector< TranslatableString >;
using MessageTable = std::vector< MessageColumn >;
protected:
@ -72,36 +72,39 @@ protected:
// Each member of a column is a string that should have no newlines,
// and each column should have the same number of elements, to make
// proper correspondences, but this is not checked.
ProgressDialog(const wxString & title,
ProgressDialog(const TranslatableString & title,
const MessageTable & columns,
int flags = pdlgDefaultFlags,
const wxString & sRemainingLabelText = {});
const TranslatableString & sRemainingLabelText = {});
public:
virtual ~ProgressDialog();
bool Create(const wxString & title,
const wxString & message = {},
bool Create(const TranslatableString & title,
const TranslatableString & message = {},
int flags = pdlgDefaultFlags,
const wxString & sRemainingLabelText = {});
const TranslatableString & sRemainingLabelText = {});
void Reinit();
protected:
bool Create(const wxString & title,
bool Create(const TranslatableString & title,
const MessageTable & columns,
int flags = pdlgDefaultFlags,
const wxString & sRemainingLabelText = {});
const TranslatableString & sRemainingLabelText = {});
public:
ProgressResult Update(int value, const wxString & message = {});
ProgressResult Update(double current, const wxString & message = {});
ProgressResult Update(double current, double total, const wxString & message = {});
ProgressResult Update(wxULongLong_t current, wxULongLong_t total, const wxString & message = {});
ProgressResult Update(wxLongLong current, wxLongLong total, const wxString & message = {});
ProgressResult Update(wxLongLong_t current, wxLongLong_t total, const wxString & message = {});
ProgressResult Update(int current, int total, const wxString & message = {});
void SetMessage(const wxString & message);
ProgressResult Update(int value, const TranslatableString & message = {});
ProgressResult Update(double current, const TranslatableString & message = {});
ProgressResult Update(double current, double total, const TranslatableString & message = {});
ProgressResult Update(wxULongLong_t current, wxULongLong_t total, const TranslatableString & message = {});
ProgressResult Update(wxLongLong current, wxLongLong total, const TranslatableString & message = {});
ProgressResult Update(wxLongLong_t current, wxLongLong_t total, const TranslatableString & message = {});
ProgressResult Update(int current, int total, const TranslatableString & message = {});
void SetMessage(const TranslatableString & message);
// overloads and hides the inherited function that takes naked wxString:
void SetTitle(const TranslatableString & title);
protected:
wxWindowRef mHadFocus;
@ -156,10 +159,10 @@ class AUDACITY_DLL_API TimerProgressDialog final : public ProgressDialog
{
public:
TimerProgressDialog(const wxLongLong_t duration,
const wxString &title,
const TranslatableString &title,
const MessageTable & columns,
int flags = pdlgDefaultFlags,
const wxString & sRemainingLabelText = {});
const TranslatableString & sRemainingLabelText = {});
// Oh no, there is an inherited nullary "Update" in wxDialog!
// Choose another name then...