TranslatableString in AudacityCommand::MessageBox, Effect::MessageBox

This commit is contained in:
Paul Licameli 2019-12-19 14:19:51 -05:00
parent ae42397d64
commit d8c2610d88
18 changed files with 254 additions and 168 deletions

View File

@ -168,12 +168,9 @@ bool AudacityCommand::SetAutomationParameters(const wxString & parms)
if (!S.bOK)
{
AudacityCommand::MessageBox(
wxString::Format(
_("%s: Could not load settings below. Default settings will be used.\n\n%s"),
GetName().Translation(),
preset
)
);
XO(
"%s: Could not load settings below. Default settings will be used.\n\n%s")
.Format( GetName(), preset ) );
// fror now always succeed, so that we can prompt the user.
return true;
@ -241,14 +238,15 @@ bool AudacityCommand::TransferDataFromWindow()
return true;
}
int AudacityCommand::MessageBox(const wxString& message, long style, const wxString &titleStr)
int AudacityCommand::MessageBox(
const TranslatableString& message, long style,
const TranslatableString &titleStr)
{
wxString title;
if (titleStr.empty())
title = GetName().Translation();
else
title = wxString::Format(_("%s: %s"), GetName().Translation(), titleStr);
return AudacityMessageBox(message, title, style, mUIParent);
auto title = titleStr.empty()
? GetName()
: XO("%s: %s").Format( GetName(), titleStr );
return AudacityMessageBox(
message.Translation(), title.Translation(), style, mUIParent);
}
BEGIN_EVENT_TABLE(AudacityCommandDialog, wxDialogWrapper)

View File

@ -86,9 +86,9 @@ class AUDACITY_DLL_API AudacityCommand /* not final */ : public wxEvtHandler,
// Display a message box, using effect's (translated) name as the prefix
// for the title.
enum : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };
int MessageBox(const wxString& message,
int MessageBox(const TranslatableString& message,
long style = DefaultMessageBoxStyle,
const wxString& titleStr = wxString{});
const TranslatableString& titleStr = {});
//
// protected virtual methods

View File

@ -228,11 +228,11 @@ bool EffectAutoDuck::Init()
},
[&](const Track *) {
Effect::MessageBox(
_("You selected a track which does not contain audio. AutoDuck can only process audio tracks."),
/* i18n-hint: Auto duck is the name of an effect that 'ducks' (reduces the volume)
* of the audio automatically when there is sound on another track. Not as
* in 'Donald-Duck'!*/
wxICON_ERROR);
XO("You selected a track which does not contain audio. AutoDuck can only process audio tracks."),
wxICON_ERROR );
return false;
}
);
@ -244,8 +244,11 @@ bool EffectAutoDuck::Init()
if (!controlTrackCandidate)
{
Effect::MessageBox(
_("Auto Duck needs a control track which must be placed below the selected track(s)."),
wxICON_ERROR);
/* i18n-hint: Auto duck is the name of an effect that 'ducks' (reduces the volume)
* of the audio automatically when there is sound on another track. Not as
* in 'Donald-Duck'!*/
XO("Auto Duck needs a control track which must be placed below the selected track(s)."),
wxICON_ERROR );
return false;
}

View File

@ -197,8 +197,8 @@ bool EffectClickRemoval::Process()
}
if (bGoodResult && !mbDidSomething) // Processing successful, but ineffective.
Effect::MessageBox(
_("Algorithm not effective on this audio. Nothing changed."),
wxOK | wxICON_ERROR);
XO("Algorithm not effective on this audio. Nothing changed."),
wxOK | wxICON_ERROR );
this->ReplaceProcessedTracks(bGoodResult && mbDidSomething);
return bGoodResult && mbDidSomething;
@ -209,9 +209,9 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st
if (len <= windowSize / 2)
{
Effect::MessageBox(
wxString::Format(_("Selection must be larger than %d samples."),
windowSize / 2),
wxOK | wxICON_ERROR);
XO("Selection must be larger than %d samples.")
.Format(windowSize / 2),
wxOK | wxICON_ERROR );
return false;
}

View File

@ -105,7 +105,7 @@ bool EffectEcho::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames
history.reinit(histLen, true);
}
catch ( const std::bad_alloc& ) {
Effect::MessageBox(_("Requested value exceeds memory capacity."));
Effect::MessageBox( XO("Requested value exceeds memory capacity.") );
return false;
}

View File

@ -1081,12 +1081,8 @@ bool Effect::SetAutomationParameters(const wxString & parms)
if (!success)
{
Effect::MessageBox(
wxString::Format(
_("%s: Could not load settings below. Default settings will be used.\n\n%s"),
GetName().Translation(),
preset
)
);
XO("%s: Could not load settings below. Default settings will be used.\n\n%s")
.Format( GetName(), preset ) );
// We are using defualt settings and we still wish to continue.
return true;
//return false;
@ -2451,15 +2447,14 @@ void Effect::Preview(bool dryOnly)
}
}
int Effect::MessageBox
(const wxString& message, long style, const wxString &titleStr)
int Effect::MessageBox( const TranslatableString& message,
long style, const TranslatableString &titleStr)
{
wxString title;
if (titleStr.empty())
title = GetName().Translation();
else
title = wxString::Format(_("%s: %s"), GetName().Translation(), titleStr);
return AudacityMessageBox(message, title, style, mUIParent);
auto title = titleStr.empty()
? GetName()
: XO("%s: %s").Format( GetName(), titleStr );
return AudacityMessageBox(
message.Translation(), title.Translation(), style, mUIParent );
}
BEGIN_EVENT_TABLE(EffectDialog, wxDialogWrapper)

View File

@ -269,9 +269,9 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
// Display a message box, using effect's (translated) name as the prefix
// for the title.
enum : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };
int MessageBox(const wxString& message,
int MessageBox(const TranslatableString& message,
long style = DefaultMessageBoxStyle,
const wxString& titleStr = wxString{});
const TranslatableString& titleStr = {});
static void IncEffectCounter(){ nEffectsDone++;};

View File

@ -505,9 +505,10 @@ bool EffectEqualization::ValidateUI()
{
// PRL: This is unreachable. mDisallowCustom is always false.
Effect::MessageBox(_("To use this filter curve in a macro, please choose a new name for it.\nChoose the 'Save/Manage Curves...' button and rename the 'unnamed' curve, then use that one."),
Effect::MessageBox(
XO("To use this filter curve in a macro, please choose a new name for it.\nChoose the 'Save/Manage Curves...' button and rename the 'unnamed' curve, then use that one."),
wxOK | wxCENTRE,
_("Filter Curve needs a different name"));
XO("Filter Curve needs a different name") );
return false;
}
@ -626,7 +627,9 @@ bool EffectEqualization::Init()
for (auto track : trackRange) {
if (track->GetRate() != rate) {
Effect::MessageBox(_("To apply Equalization, all selected tracks must have the same sample rate."));
Effect::MessageBox(
XO(
"To apply Equalization, all selected tracks must have the same sample rate.") );
return(false);
}
++selcount;
@ -636,9 +639,10 @@ bool EffectEqualization::Init()
mHiFreq = rate / 2.0;
// Unlikely, but better than crashing.
if (mHiFreq <= loFreqI) {
Effect::MessageBox( _("Track sample rate is too low for this effect."),
wxOK | wxCENTRE,
_("Effect Unavailable"));
Effect::MessageBox(
XO("Track sample rate is too low for this effect."),
wxOK | wxCENTRE,
XO("Effect Unavailable") );
return(false);
}
@ -1601,13 +1605,15 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append)
const wxString fullPath{ fn.GetFullPath() };
if( !reader.Parse( this, fullPath ) )
{
wxString msg;
/* i18n-hint: EQ stands for 'Equalization'.*/
msg.Printf(_("Error Loading EQ Curves from file:\n%s\nError message says:\n%s"), fullPath, reader.GetErrorStr());
auto msg = XO(
"Error Loading EQ Curves from file:\n%s\nError message says:\n%s")
.Format( fullPath, reader.GetErrorStr() );
// Inform user of load failure
Effect::MessageBox( msg,
Effect::MessageBox(
msg,
wxOK | wxCENTRE,
_("Error Loading EQ Curves"));
XO("Error Loading EQ Curves") );
mCurves.push_back( _("unnamed") ); // we always need a default curve to use
return;
}
@ -2002,9 +2008,10 @@ void EffectEqualization::setCurve(const wxString &curveName)
break;
if( i == mCurves.size())
{
Effect::MessageBox( _("Requested curve not found, using 'unnamed'"),
Effect::MessageBox(
XO("Requested curve not found, using 'unnamed'"),
wxOK|wxICON_ERROR,
_("Curve not found") );
XO("Curve not found") );
setCurve();
}
else
@ -3411,9 +3418,10 @@ void EditCurvesDialog::OnUp(wxCommandEvent & WXUNUSED(event))
{
if ( item == mList->GetItemCount()-1)
{ // 'unnamed' always stays at the bottom
mEffect->Effect::MessageBox(_("'unnamed' always stays at the bottom of the list"),
Effect::DefaultMessageBoxStyle,
_("'unnamed' is special")); // these could get tedious!
mEffect->Effect::MessageBox(
XO("'unnamed' always stays at the bottom of the list"),
Effect::DefaultMessageBoxStyle,
XO("'unnamed' is special") ); // these could get tedious!
return;
}
state = mList->GetItemState(item-1, wxLIST_STATE_SELECTED);
@ -3533,12 +3541,16 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event))
bad = true;
if( curve == item ) // trying to rename a curve with the same name
{
mEffect->Effect::MessageBox( _("Name is the same as the original one"), wxOK, _("Same name") );
mEffect->Effect::MessageBox(
XO("Name is the same as the original one"),
wxOK,
XO("Same name") );
break;
}
int answer = mEffect->Effect::MessageBox(
wxString::Format( _("Overwrite existing curve '%s'?"), name ),
wxYES_NO, _("Curve exists") );
XO("Overwrite existing curve '%s'?").Format( name ),
wxYES_NO,
XO("Curve exists") );
if (answer == wxYES)
{
bad = false;
@ -3609,18 +3621,22 @@ void EditCurvesDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
{
if(item == mList->GetItemCount()-1) //unnamed
{
mEffect->Effect::MessageBox(_("You cannot delete the 'unnamed' curve."),
wxOK | wxCENTRE, _("Can't delete 'unnamed'"));
mEffect->Effect::MessageBox(
XO("You cannot delete the 'unnamed' curve."),
wxOK | wxCENTRE,
XO("Can't delete 'unnamed'") );
}
else
{
// Create the prompt
wxString quest;
quest = wxString::Format(_("Delete '%s'?"),
mEditCurves[ item-deleted ].Name);
auto quest = XO("Delete '%s'?")
.Format(mEditCurves[ item-deleted ].Name));
// Ask for confirmation before removal
int ans = mEffect->Effect::MessageBox( quest, wxYES_NO | wxCENTRE, _("Confirm Deletion") );
int ans = mEffect->Effect::MessageBox(
quest,
wxYES_NO | wxCENTRE,
XO("Confirm Deletion") );
if( ans == wxYES )
{ // Remove the curve from the array
mEditCurves.RemoveAt( item-deleted );
@ -3641,16 +3657,19 @@ void EditCurvesDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
int count = mList->GetSelectedItemCount();
long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
// Create the prompt
wxString quest;
TranslatableString quest;
if( count > 1 )
quest = wxString::Format(_("Delete %d items?"), count);
quest = XO("Delete %d items?").Format( count );
else
if( count == 1 )
quest = wxString::Format(_("Delete '%s'?"), mEditCurves[ item ].Name);
quest = XO("Delete '%s'?").Format( mEditCurves[ item ].Name );
else
return;
// Ask for confirmation before removal
int ans = mEffect->Effect::MessageBox( quest, wxYES_NO | wxCENTRE, _("Confirm Deletion") );
int ans = mEffect->Effect::MessageBox(
quest,
wxYES_NO | wxCENTRE,
XO("Confirm Deletion") );
if( ans == wxYES )
{ // Remove the curve(s) from the array
// Take care, mList and mEditCurves will get out of sync as curves are deleted
@ -3660,9 +3679,10 @@ void EditCurvesDialog::OnDelete(wxCommandEvent & WXUNUSED(event))
// TODO: Migrate to the standard "Manage" dialog.
if(item == mList->GetItemCount()-1) //unnamed
{
mEffect->Effect::MessageBox(_("You cannot delete the 'unnamed' curve, it is special."),
Effect::DefaultMessageBoxStyle,
_("Can't delete 'unnamed'"));
mEffect->Effect::MessageBox(
XO("You cannot delete the 'unnamed' curve, it is special."),
Effect::DefaultMessageBoxStyle,
XO("Can't delete 'unnamed'") );
}
else
{
@ -3724,9 +3744,10 @@ void EditCurvesDialog::OnExport( wxCommandEvent & WXUNUSED(event))
i++;
}
else
mEffect->Effect::MessageBox(_("You cannot export 'unnamed' curve, it is special."),
Effect::DefaultMessageBoxStyle,
_("Cannot Export 'unnamed'"));
mEffect->Effect::MessageBox(
XO("You cannot export 'unnamed' curve, it is special."),
Effect::DefaultMessageBoxStyle,
XO("Cannot Export 'unnamed'") );
// get next selected item
item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
}
@ -3735,16 +3756,17 @@ void EditCurvesDialog::OnExport( wxCommandEvent & WXUNUSED(event))
mEffect->mCurves = exportCurves;
mEffect->SaveCurves(fileName);
mEffect->mCurves = temp;
wxString message;
message.Printf(_("%d curves exported to %s"), i, fileName);
mEffect->Effect::MessageBox(message,
Effect::DefaultMessageBoxStyle,
_("Curves exported"));
auto message = XO("%d curves exported to %s").Format( i, fileName );
mEffect->Effect::MessageBox(
message,
Effect::DefaultMessageBoxStyle,
XO("Curves exported") );
}
else
mEffect->Effect::MessageBox(_("No curves exported"),
Effect::DefaultMessageBoxStyle,
_("No curves exported"));
mEffect->Effect::MessageBox(
XO("No curves exported"),
Effect::DefaultMessageBoxStyle,
XO("No curves exported") );
}
void EditCurvesDialog::OnLibrary( wxCommandEvent & WXUNUSED(event))

View File

@ -500,8 +500,14 @@ bool EffectEqualization48x::Benchmark(EffectEqualization* effectEqualization)
wxTimeSpan tsDefault(0, 0, 0, times[4]);
mEffectEqualization->MessageBox(
wxString::Format(_("Benchmark times:\nOriginal: %s\nDefault Segmented: %s\nDefault Threaded: %s\nSSE: %s\nSSE Threaded: %s\n"),tsDefault.Format(wxT("%M:%S.%l")),
tsDefaultEnhanced.Format(wxT("%M:%S.%l")), tsDefaultThreaded.Format(wxT("%M:%S.%l")),tsSSE.Format(wxT("%M:%S.%l")),tsSSEThreaded.Format(wxT("%M:%S.%l"))));
XO(
"Benchmark times:\nOriginal: %s\nDefault Segmented: %s\nDefault Threaded: %s\nSSE: %s\nSSE Threaded: %s\n")
.Format(
tsDefault.Format(wxT("%M:%S.%l")),
tsDefaultEnhanced.Format(wxT("%M:%S.%l")),
tsDefaultThreaded.Format(wxT("%M:%S.%l")),
tsSSE.Format(wxT("%M:%S.%l")),
tsSSEThreaded.Format(wxT("%M:%S.%l")) ) );
return bBreakLoop; // return !bBreakLoop ?
}

View File

@ -171,7 +171,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt,
buffer.reinit(blockSize);
}
catch( const std::bad_alloc & ) {
Effect::MessageBox(_("Requested value exceeds memory capacity."));
Effect::MessageBox( XO("Requested value exceeds memory capacity.") );
return false;
}

View File

@ -52,9 +52,9 @@ bool Generator::Process()
!track->IsEmpty(mT0, mT0+GetDuration()-(mT1-mT0)-1.0/track->GetRate()))
{
Effect::MessageBox(
_("There is not enough room available to generate the audio"),
wxICON_STOP,
_("Error"));
XO("There is not enough room available to generate the audio"),
wxICON_STOP,
XO("Error") );
Failure();
bGoodResult = false;
return;

View File

@ -586,17 +586,21 @@ bool EffectNoiseReduction::Settings::PrefsIO(bool read)
bool EffectNoiseReduction::Settings::Validate(EffectNoiseReduction *effect) const
{
if (StepsPerWindow() < windowTypesInfo[mWindowTypes].minSteps) {
effect->Effect::MessageBox(_("Steps per block are too few for the window types."));
effect->Effect::MessageBox(
XO("Steps per block are too few for the window types.") );
return false;
}
if (StepsPerWindow() > WindowSize()) {
effect->Effect::MessageBox(_("Steps per block cannot exceed the window size."));
effect->Effect::MessageBox(
XO("Steps per block cannot exceed the window size.") );
return false;
}
if (mMethod == DM_MEDIAN && StepsPerWindow() > 4) {
effect->Effect::MessageBox(_("Median method is not implemented for more than four steps per window."));
effect->Effect::MessageBox(
XO(
"Median method is not implemented for more than four steps per window.") );
return false;
}
@ -622,12 +626,14 @@ bool EffectNoiseReduction::Process()
}
else if (mStatistics->mWindowSize != mSettings->WindowSize()) {
// possible only with advanced settings
::Effect::MessageBox(_("You must specify the same window size for steps 1 and 2."));
::Effect::MessageBox(
XO("You must specify the same window size for steps 1 and 2.") );
return false;
}
else if (mStatistics->mWindowTypes != mSettings->mWindowTypes) {
// A warning only
::Effect::MessageBox(_("Warning: window types are not the same as for profiling."));
::Effect::MessageBox(
XO("Warning: window types are not the same as for profiling.") );
}
Worker worker(*mSettings, mStatistics->mRate
@ -659,9 +665,12 @@ bool EffectNoiseReduction::Worker::Process
for ( auto track : tracks.Selected< WaveTrack >() ) {
if (track->GetRate() != mSampleRate) {
if (mDoProfile)
effect.Effect::MessageBox(_("All noise profile data must have the same sample rate."));
effect.Effect::MessageBox(
XO("All noise profile data must have the same sample rate.") );
else
effect.Effect::MessageBox(_("The sample rate of the noise profile must match that of the sound to be processed."));
effect.Effect::MessageBox(
XO(
"The sample rate of the noise profile must match that of the sound to be processed.") );
return false;
}
@ -684,7 +693,8 @@ bool EffectNoiseReduction::Worker::Process
if (mDoProfile) {
if (statistics.mTotalWindows == 0) {
effect.Effect::MessageBox(_("Selected noise profile is too short."));
effect.Effect::MessageBox(
XO("Selected noise profile is too short.") );
return false;
}
}

View File

@ -256,7 +256,8 @@ size_t EffectPaulstretch::GetBufferSize(double rate)
bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int count)
{
auto badAllocMessage = _("Requested value exceeds memory capacity.");
const auto badAllocMessage =
XO("Requested value exceeds memory capacity.");
const auto stretch_buf_size = GetBufferSize(track->GetRate());
if (stretch_buf_size == 0) {
@ -289,30 +290,35 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
/* i18n-hint: 'Time Resolution' is the name of a control in the Paulstretch effect.*/
if ((minDuration / mProjectRate) < defaultPreviewLen) {
::Effect::MessageBox (wxString::Format(_("Audio selection too short to preview.\n\n"
"Try increasing the audio selection to at least %.1f seconds,\n"
"or reducing the 'Time Resolution' to less than %.1f seconds."),
(minDuration / track->GetRate()) + 0.05, // round up to 1/10 s.
floor(maxTimeRes * 10.0) / 10.0),
wxOK | wxICON_EXCLAMATION);
::Effect::MessageBox(
XO("Audio selection too short to preview.\n\n"
"Try increasing the audio selection to at least %.1f seconds,\n"
"or reducing the 'Time Resolution' to less than %.1f seconds.")
.Format(
(minDuration / track->GetRate()) + 0.05, // round up to 1/10 s.
floor(maxTimeRes * 10.0) / 10.0),
wxOK | wxICON_EXCLAMATION );
}
else {
/* i18n-hint: 'Time Resolution' is the name of a control in the Paulstretch effect.*/
::Effect::MessageBox (wxString::Format(_("Unable to Preview.\n\n"
"For the current audio selection, the maximum\n"
"'Time Resolution' is %.1f seconds."),
floor(maxTimeRes * 10.0) / 10.0),
wxOK | wxICON_EXCLAMATION);
::Effect::MessageBox(
XO("Unable to Preview.\n\n"
"For the current audio selection, the maximum\n"
"'Time Resolution' is %.1f seconds.")
.Format( floor(maxTimeRes * 10.0) / 10.0 ),
wxOK | wxICON_EXCLAMATION );
}
}
else {
/* i18n-hint: 'Time Resolution' is the name of a control in the Paulstretch effect.*/
::Effect::MessageBox (wxString::Format(_("The 'Time Resolution' is too long for the selection.\n\n"
"Try increasing the audio selection to at least %.1f seconds,\n"
"or reducing the 'Time Resolution' to less than %.1f seconds."),
(minDuration / track->GetRate()) + 0.05, // round up to 1/10 s.
floor(maxTimeRes * 10.0) / 10.0),
wxOK | wxICON_EXCLAMATION);
::Effect::MessageBox(
XO("The 'Time Resolution' is too long for the selection.\n\n"
"Try increasing the audio selection to at least %.1f seconds,\n"
"or reducing the 'Time Resolution' to less than %.1f seconds.")
.Format(
(minDuration / track->GetRate()) + 0.05, // round up to 1/10 s.
floor(maxTimeRes * 10.0) / 10.0),
wxOK | wxICON_EXCLAMATION );
}
return false;

View File

@ -88,7 +88,9 @@ bool EffectRepair::Process()
const auto repair1 = track->TimeToLongSamples(repair_t1);
const auto repairLen = repair1 - repair0;
if (repairLen > 128) {
::Effect::MessageBox(_("The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair."));
::Effect::MessageBox(
XO(
"The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair.") );
bGoodResult = false;
break;
}
@ -105,8 +107,10 @@ bool EffectRepair::Process()
const auto len = s1 - s0;
if (s0 == repair0 && s1 == repair1) {
::Effect::MessageBox(_("Repair works by using audio data outside the selection region.\n\nPlease select a region that has audio touching at least one side of it.\n\nThe more surrounding audio, the better it performs."));
/// The Repair effect needs some data to go on.\n\nPlease select an area to repair with some audio on at least one side (the more the better)."));
::Effect::MessageBox(
XO(
"Repair works by using audio data outside the selection region.\n\nPlease select a region that has audio touching at least one side of it.\n\nThe more surrounding audio, the better it performs.") );
/// The Repair effect needs some data to go on.\n\nPlease select an area to repair with some audio on at least one side (the more the better).") );
bGoodResult = false;
break;
}

View File

@ -348,7 +348,9 @@ bool EffectScienFilter::Init()
{
if (t->GetRate() != rate)
{
Effect::MessageBox(_("To apply a filter, all selected tracks must have the same sample rate."));
Effect::MessageBox(
XO(
"To apply a filter, all selected tracks must have the same sample rate.") );
return false;
}
}

View File

@ -343,7 +343,9 @@ bool EffectTruncSilence::ProcessIndependently()
- [&](const Track *pTrack){
return channels.contains(pTrack); };
if (otherTracks) {
::Effect::MessageBox(_("When truncating independently, there may only be one selected audio track in each Sync-Locked Track Group."));
::Effect::MessageBox(
XO(
"When truncating independently, there may only be one selected audio track in each Sync-Locked Track Group.") );
return false;
}
}

View File

@ -560,10 +560,12 @@ bool NyquistEffect::Init()
}
if (!bAllowSpectralEditing || ((mF0 < 0.0) && (mF1 < 0.0))) {
Effect::MessageBox(_("To use 'Spectral effects', enable 'Spectral Selection'\n"
Effect::MessageBox(
XO("To use 'Spectral effects', enable 'Spectral Selection'\n"
"in the track Spectrogram settings and select the\n"
"frequency range for the effect to act on."),
wxOK | wxICON_EXCLAMATION | wxCENTRE, _("Error"));
wxOK | wxICON_EXCLAMATION | wxCENTRE,
XO("Error") );
return false;
}
@ -775,8 +777,11 @@ bool NyquistEffect::Process()
// Nyquist Prompt does not require a selection, but effects do.
if (!bOnePassTool && (mNumSelectedChannels == 0)) {
wxString message = _("Audio selection required.");
Effect::MessageBox(message, wxOK | wxCENTRE | wxICON_EXCLAMATION, _("Nyquist Error"));
auto message = XO("Audio selection required.");
Effect::MessageBox(
message,
wxOK | wxCENTRE | wxICON_EXCLAMATION,
XO("Nyquist Error") );
}
Maybe<TrackIterRange<WaveTrack>> pRange;
@ -808,8 +813,10 @@ bool NyquistEffect::Process()
mCurTrack[1] = * ++ channels.first;
if (mCurTrack[1]->GetRate() != mCurTrack[0]->GetRate()) {
Effect::MessageBox(_("Sorry, cannot apply effect on stereo tracks where the tracks don't match."),
wxOK | wxCENTRE);
Effect::MessageBox(
XO(
"Sorry, cannot apply effect on stereo tracks where the tracks don't match."),
wxOK | wxCENTRE );
success = false;
goto finish;
}
@ -827,11 +834,14 @@ bool NyquistEffect::Process()
if (mCurLen > NYQ_MAX_LEN) {
float hours = (float)NYQ_MAX_LEN / (44100 * 60 * 60);
const auto message = wxString::Format(
_("Selection too long for Nyquist code.\nMaximum allowed selection is %ld samples\n(about %.1f hours at 44100 Hz sample rate)."),
(long)NYQ_MAX_LEN, hours
);
Effect::MessageBox(message, wxOK | wxCENTRE, _("Nyquist Error"));
const auto message =
XO(
"Selection too long for Nyquist code.\nMaximum allowed selection is %ld samples\n(about %.1f hours at 44100 Hz sample rate).")
.Format((long)NYQ_MAX_LEN, hours);
Effect::MessageBox(
message,
wxOK | wxCENTRE,
XO("Nyquist Error") );
if (!mProjectChanged)
em.SetSkipStateFlag(true);
return false;
@ -1385,9 +1395,12 @@ bool NyquistEffect::ProcessOne()
}
if (rval == nyx_string) {
wxString msg = NyquistToWxString(nyx_get_string());
// Assume the string has already been translated within the Lisp runtime
// if necessary, by gettext or ngettext defined below, before it is
// communicated back to C++
auto msg = Verbatim( NyquistToWxString(nyx_get_string()) );
if (!msg.empty()) // Empty string may be used as a No-Op return value.
Effect::MessageBox(msg);
Effect::MessageBox( msg );
else
return true;
@ -1399,18 +1412,16 @@ bool NyquistEffect::ProcessOne()
}
if (rval == nyx_double) {
wxString str;
str.Printf(_("Nyquist returned the value: %f"),
nyx_get_double());
Effect::MessageBox(str);
auto str = XO("Nyquist returned the value: %f")
.Format(nyx_get_double());
Effect::MessageBox( str );
return (GetType() != EffectTypeProcess || mIsPrompt);
}
if (rval == nyx_int) {
wxString str;
str.Printf(_("Nyquist returned the value: %d"),
nyx_get_int());
Effect::MessageBox(str);
auto str = XO("Nyquist returned the value: %d")
.Format(nyx_get_int());
Effect::MessageBox( str );
return (GetType() != EffectTypeProcess || mIsPrompt);
}
@ -1440,17 +1451,18 @@ bool NyquistEffect::ProcessOne()
int outChannels = nyx_get_audio_num_channels();
if (outChannels > (int)mCurNumChannels) {
Effect::MessageBox(_("Nyquist returned too many audio channels.\n"));
Effect::MessageBox( XO("Nyquist returned too many audio channels.\n") );
return false;
}
if (outChannels == -1) {
Effect::MessageBox(_("Nyquist returned one audio channel as an array.\n"));
Effect::MessageBox(
XO("Nyquist returned one audio channel as an array.\n") );
return false;
}
if (outChannels == 0) {
Effect::MessageBox(_("Nyquist returned an empty array.\n"));
Effect::MessageBox( XO("Nyquist returned an empty array.\n") );
return false;
}
@ -1495,7 +1507,7 @@ bool NyquistEffect::ProcessOne()
mOutputTime = outputTrack[i]->GetEndTime();
if (mOutputTime <= 0) {
Effect::MessageBox(_("Nyquist returned nil audio.\n"));
Effect::MessageBox( XO("Nyquist returned nil audio.\n") );
return false;
}
}
@ -2054,7 +2066,10 @@ bool NyquistEffect::Parse(
tokens[3], mFileName.GetFullPath());
// Too disturbing to show alert before Audacity frame is up.
// Effect::MessageBox(str, wxT("Nyquist Warning"), wxOK | wxICON_EXCLAMATION);
// Effect::MessageBox(
// str,
// wxOK | wxICON_EXCLAMATION,
// XO("Nyquist Warning") );
// Note that the AudacityApp's mLogger has not yet been created,
// so this brings up an alert box, but after the Audacity frame is up.
@ -2201,11 +2216,13 @@ bool NyquistEffect::ParseProgram(wxInputStream & stream)
{
/* i1n-hint: SAL and LISP are names for variant syntaxes for the
Nyquist programming language. Leave them, and 'return', untranslated. */
Effect::MessageBox(_("Your code looks like SAL syntax, but there is no \'return\' statement.\n\
Effect::MessageBox(
XO(
"Your code looks like SAL syntax, but there is no \'return\' statement.\n\
For SAL, use a return statement such as:\n\treturn *track* * 0.1\n\
or for LISP, begin with an open parenthesis such as:\n\t(mult *track* 0.1)\n ."),
Effect::DefaultMessageBoxStyle,
_("Error in Nyquist code"));
Effect::DefaultMessageBoxStyle,
XO("Error in Nyquist code") );
/* i18n-hint: refers to programming "languages" */
mInitError = _("Could not determine language");
return false;
@ -2486,8 +2503,12 @@ bool NyquistEffect::TransferDataFromEffectWindow()
wxString token = tokenizer.GetNextToken();
if(!validatePath(token))
{
const auto message = wxString::Format(_("\"%s\" is not a valid file path."), token);
Effect::MessageBox(message, wxOK | wxICON_EXCLAMATION | wxCENTRE, _("Error"));
const auto message =
XO("\"%s\" is not a valid file path.").Format( token );
Effect::MessageBox(
message,
wxOK | wxICON_EXCLAMATION | wxCENTRE,
XO("Error") );
return false;
}
}
@ -2496,8 +2517,12 @@ bool NyquistEffect::TransferDataFromEffectWindow()
else
{
/* i18n-hint: Warning that there is one quotation mark rather than a pair.*/
const auto message = wxString::Format(_("Mismatched quotes in\n%s"), ctrl->valStr);
Effect::MessageBox(message, wxOK | wxICON_EXCLAMATION | wxCENTRE, _("Error"));
const auto message =
XO("Mismatched quotes in\n%s").Format( ctrl->valStr );
Effect::MessageBox(
message,
wxOK | wxICON_EXCLAMATION | wxCENTRE,
XO("Error") );
return false;
}
}
@ -2508,8 +2533,12 @@ bool NyquistEffect::TransferDataFromEffectWindow()
}
// Validation failed
const auto message = wxString::Format(_("\"%s\" is not a valid file path."), ctrl->valStr);
Effect::MessageBox(message, wxOK | wxICON_EXCLAMATION | wxCENTRE, _("Error"));
const auto message =
XO("\"%s\" is not a valid file path.").Format( ctrl->valStr );
Effect::MessageBox(
message,
wxOK | wxICON_EXCLAMATION | wxCENTRE,
XO("Error") );
return false;
}
@ -2781,8 +2810,9 @@ void NyquistEffect::OnLoad(wxCommandEvent & WXUNUSED(evt))
{
if (mCommandText->IsModified())
{
if (Effect::MessageBox(_("Current program has been modified.\nDiscard changes?"),
wxYES_NO) == wxNO)
if (wxNO == Effect::MessageBox(
XO("Current program has been modified.\nDiscard changes?"),
wxYES_NO ) )
{
return;
}
@ -2805,7 +2835,7 @@ void NyquistEffect::OnLoad(wxCommandEvent & WXUNUSED(evt))
if (!mCommandText->LoadFile(mFileName.GetFullPath()))
{
Effect::MessageBox(_("File could not be loaded"));
Effect::MessageBox( XO("File could not be loaded") );
}
}
@ -2828,7 +2858,7 @@ void NyquistEffect::OnSave(wxCommandEvent & WXUNUSED(evt))
if (!mCommandText->SaveFile(mFileName.GetFullPath()))
{
Effect::MessageBox(_("File could not be saved"));
Effect::MessageBox( XO("File could not be saved") );
}
}
@ -2882,9 +2912,12 @@ void NyquistEffect::OnTime(wxCommandEvent& evt)
// so skip if value has not changed.
if (val != value) {
if (val < ctrl.low || val > ctrl.high) {
const auto message = wxString::Format(_("Value range:\n%s to %s"),
ToTimeFormat(ctrl.low), ToTimeFormat(ctrl.high));
Effect::MessageBox(message, wxOK | wxCENTRE, _("Value Error"));
const auto message = XO("Value range:\n%s to %s")
.Format( ToTimeFormat(ctrl.low), ToTimeFormat(ctrl.high) );
Effect::MessageBox(
message,
wxOK | wxCENTRE,
XO("Value Error") );
}
if (val < ctrl.low)
@ -2923,9 +2956,11 @@ void NyquistEffect::OnFileButton(wxCommandEvent& evt)
// Users should not normally see this, unless they are writing Nyquist plug-ins.
if (wildcards % 2 != 0 || !validWildcards || ctrl.lowStr.EndsWith("|"))
{
Effect::MessageBox(_("Invalid wildcard string in 'path' control.'\n"
"Using empty string instead."),
wxOK | wxICON_EXCLAMATION | wxCENTRE, _("Error"));
Effect::MessageBox(
XO("Invalid wildcard string in 'path' control.'\n"
"Using empty string instead."),
wxOK | wxICON_EXCLAMATION | wxCENTRE,
XO("Error") );
ctrl.lowStr = "";
}
}

View File

@ -313,7 +313,9 @@ bool VampEffect::Init()
// So is this check not adequate?
{
// TODO: more-than-two-channels-message
Effect::MessageBox(_("Sorry, Vamp Plug-ins cannot be run on stereo tracks where the individual channels of the track do not match."));
Effect::MessageBox(
XO(
"Sorry, Vamp Plug-ins cannot be run on stereo tracks where the individual channels of the track do not match.") );
return false;
}
}
@ -332,7 +334,7 @@ bool VampEffect::Init()
mPlugin.reset(loader->loadPlugin(mKey, mRate, Vamp::HostExt::PluginLoader::ADAPT_ALL));
if (!mPlugin)
{
Effect::MessageBox(_("Sorry, failed to load Vamp Plug-in."));
Effect::MessageBox( XO("Sorry, failed to load Vamp Plug-in.") );
return false;
}
@ -428,7 +430,8 @@ bool VampEffect::Process()
{
if (!mPlugin->initialise(channels, step, block))
{
Effect::MessageBox(_("Sorry, Vamp Plug-in failed to initialize."));
Effect::MessageBox(
XO("Sorry, Vamp Plug-in failed to initialize.") );
return false;
}
}