ShuttleGui::AddChoice and TieChoice take TranslatableStrings

This commit is contained in:
Paul Licameli 2019-12-17 22:52:42 -05:00
parent 66097c34dc
commit 75996a851c
42 changed files with 174 additions and 179 deletions

View File

@ -401,9 +401,9 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S)
{
/*i18n-hint: One of the choices of what you want Audacity to do when
* Audacity finds a project depends on another file.*/
_("Ask me") ,
_("Always copy all files (safest)") ,
_("Never copy any files") ,
XO("Ask me") ,
XO("Always copy all files (safest)") ,
XO("Never copy any files") ,
},
0 // "Ask me"
);

View File

@ -214,43 +214,43 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
if (!p)
return;
wxArrayStringEx algChoices{
_("Spectrum") ,
_("Standard Autocorrelation") ,
_("Cuberoot Autocorrelation") ,
_("Enhanced Autocorrelation") ,
TranslatableStrings algChoices{
XO("Spectrum") ,
XO("Standard Autocorrelation") ,
XO("Cuberoot Autocorrelation") ,
XO("Enhanced Autocorrelation") ,
/* i18n-hint: This is a technical term, derived from the word
* "spectrum". Do not translate it unless you are sure you
* know the correct technical word in your language. */
_("Cepstrum") ,
XO("Cepstrum") ,
};
wxArrayStringEx sizeChoices{
wxT("128") ,
wxT("256") ,
wxT("512") ,
wxT("1024") ,
wxT("2048") ,
wxT("4096") ,
wxT("8192") ,
wxT("16384") ,
wxT("32768") ,
wxT("65536") ,
TranslatableStrings sizeChoices{
Verbatim( "128" ) ,
Verbatim( "256" ) ,
Verbatim( "512" ) ,
Verbatim( "1024" ) ,
Verbatim( "2048" ) ,
Verbatim( "4096" ) ,
Verbatim( "8192" ) ,
Verbatim( "16384" ) ,
Verbatim( "32768" ) ,
Verbatim( "65536" ) ,
};
wxArrayStringEx funcChoices;
TranslatableStrings funcChoices;
for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++)
{
funcChoices.push_back(
/* i18n-hint: This refers to a "window function",
* such as Hann or Rectangular, used in the
* Frequency analyze dialog box. */
XO("%s window").Format( WindowFuncName(i) ).Translation() );
XO("%s window").Format( WindowFuncName(i) ) );
}
wxArrayStringEx axisChoices{
_("Linear frequency") ,
_("Log frequency") ,
TranslatableStrings axisChoices{
XO("Linear frequency") ,
XO("Log frequency") ,
};
mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
@ -261,7 +261,8 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
long size;
gPrefs->Read(wxT("/FrequencyPlotDialog/SizeChoice"), &mSize, 3);
sizeChoices[mSize].ToLong(&size);
// reinterpret one of the verbatim strings above as a number
sizeChoices[mSize].MSGID().GET().ToLong(&size);
mWindowSize = size;
int alg;

View File

@ -260,12 +260,12 @@ wxString Internat::StripAccelerators(const wxString &s)
return result;
}
wxArrayStringEx LocalizedStrings(
TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings)
{
return transform_range<wxArrayStringEx>(
return transform_range<TranslatableStrings>(
strings, strings + nStrings,
std::mem_fn( &EnumValueSymbol::Translation )
std::mem_fn( &EnumValueSymbol::Msgid )
);
}

View File

@ -160,7 +160,7 @@ private:
#define LAT1CTOWX(X) wxString((X), wxConvISO8859_1)
class ComponentInterfaceSymbol;
wxArrayStringEx LocalizedStrings(
TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings);
#endif

View File

@ -87,10 +87,7 @@ LangChoiceDialog::LangChoiceDialog(wxWindow * parent,
{
S.SetBorder(15);
mChoice = S.AddChoice(_("Choose Language for Audacity to use:"),
transform_container<wxArrayStringEx>(mLangNames,
// Using MSGID until AddChoice is rewritten to take
// TranslatableStrings directly
[](const TranslatableString &str){ return str.MSGID().GET(); }),
mLangNames,
lang);
}
S.EndVerticalLay();

View File

@ -258,12 +258,12 @@ EnumValueSymbols::EnumValueSymbols(
emplace_back( *iter1++, *iter2++ );
}
const wxArrayStringEx &EnumValueSymbols::GetTranslations() const
const TranslatableStrings &EnumValueSymbols::GetMsgids() const
{
if ( mTranslations.empty() )
mTranslations = transform_container<wxArrayStringEx>( *this,
std::mem_fn( &EnumValueSymbol::Translation ) );
return mTranslations;
if ( mMsgids.empty() )
mMsgids = transform_container<TranslatableStrings>( *this,
std::mem_fn( &EnumValueSymbol::Msgid ) );
return mMsgids;
}
const wxArrayStringEx &EnumValueSymbols::GetInternals() const

View File

@ -111,11 +111,11 @@ public:
wxArrayStringEx internals
);
const wxArrayStringEx &GetTranslations() const;
const TranslatableStrings &GetMsgids() const;
const wxArrayStringEx &GetInternals() const;
private:
mutable wxArrayStringEx mTranslations;
mutable TranslatableStrings mMsgids;
mutable wxArrayStringEx mInternals;
};

View File

@ -381,7 +381,7 @@ wxBitmapButton * ShuttleGuiBase::AddBitmapButton(
}
wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt,
const wxArrayStringEx &choices, int Selected )
const TranslatableStrings &choices, int Selected )
{
HandleOptionality( Prompt );
AddPrompt( Prompt );
@ -396,7 +396,8 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt,
miId,
wxDefaultPosition,
wxDefaultSize,
choices,
transform_container<wxArrayString>(
choices, std::mem_fn( &TranslatableString::Translation ) ),
GetStyle( 0 ) );
pChoice->SetMinSize( { 180, -1 } );// Use -1 for 'default size' - Platform specific.
@ -415,9 +416,10 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt,
}
wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt,
const wxArrayStringEx &choices, const wxString &Selected )
const TranslatableStrings &choices, const TranslatableString &Selected )
{
return AddChoice( Prompt, choices, choices.Index( Selected ) );
return AddChoice(
Prompt, choices, make_iterator_range( choices ).index( Selected ) );
}
void ShuttleGuiBase::AddFixedText(const wxString &Str, bool bCenter, int wrapWidth)
@ -1437,7 +1439,7 @@ wxSlider * ShuttleGuiBase::DoTieSlider( const wxString &Prompt, WrappedType & Wr
wxChoice * ShuttleGuiBase::DoTieChoice(
const wxString &Prompt,
WrappedType &WrappedRef,
const wxArrayStringEx &choices )
const TranslatableStrings &choices )
{
HandleOptionality( Prompt );
@ -1451,7 +1453,12 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
case eIsCreating:
{
if( WrappedRef.IsString() ) {
auto Selected = choices.Index( WrappedRef.ReadAsString() );
auto str = WrappedRef.ReadAsString();
auto begin = choices.begin();
auto iter = std::find_if( begin, choices.end(),
[&str]( const TranslatableString &choice ){
return str == choice.Translation(); } );
int Selected = std::distance( begin, iter );
pChoice = AddChoice( Prompt, choices, Selected );
}
else
@ -1673,7 +1680,7 @@ wxSlider * ShuttleGuiBase::TieVSlider( const wxString &Prompt, float &pos, const
wxChoice * ShuttleGuiBase::TieChoice(
const wxString &Prompt,
wxString &Selected,
const wxArrayStringEx &choices )
const TranslatableStrings &choices )
{
WrappedType WrappedRef( Selected );
return DoTieChoice( Prompt, WrappedRef, choices );
@ -1682,7 +1689,7 @@ wxChoice * ShuttleGuiBase::TieChoice(
wxChoice * ShuttleGuiBase::TieChoice(
const wxString &Prompt,
int &Selected,
const wxArrayStringEx &choices )
const TranslatableStrings &choices )
{
WrappedType WrappedRef( Selected );
return DoTieChoice( Prompt, WrappedRef, choices );
@ -1928,7 +1935,7 @@ wxChoice *ShuttleGuiBase::TieChoice(
const auto &symbols = choiceSetting.GetSymbols();
const auto &SettingName = choiceSetting.Key();
const auto &Default = choiceSetting.Default().Internal();
const auto &Choices = symbols.GetTranslations();
const auto &Choices = symbols.GetMsgids();
const auto &InternalChoices = symbols.GetInternals();
wxChoice * pChoice=(wxChoice*)NULL;
@ -1941,9 +1948,7 @@ wxChoice *ShuttleGuiBase::TieChoice(
// Put to prefs does 2 and 3.
if( DoStep(1) ) DoDataShuttle( SettingName, WrappedRef ); // Get Index from Prefs.
if( DoStep(1) ) TempIndex = TranslateToIndex( TempStr, InternalChoices ); // To an index
if( DoStep(2) )
pChoice = TieChoice( Prompt, TempIndex,
transform_container<wxArrayStringEx>(Choices, GetCustomTranslation) );
if( DoStep(2) ) pChoice = TieChoice( Prompt, TempIndex, Choices );
if( DoStep(3) ) TempStr = TranslateFromIndex( TempIndex, InternalChoices ); // To a string
if( DoStep(3) ) DoDataShuttle( SettingName, WrappedRef ); // Put into Prefs.
return pChoice;
@ -2406,6 +2411,13 @@ wxSizerItem * ShuttleGui::AddSpace( int width, int height, int prop )
return mpSizer->Add( width, height, prop );
}
void ShuttleGui::SetMinSize( wxWindow *window, const TranslatableStrings & items )
{
SetMinSize( window,
transform_container<wxArrayStringEx>(
items, std::mem_fn( &TranslatableString::Translation ) ) );
}
void ShuttleGui::SetMinSize( wxWindow *window, const wxArrayStringEx & items )
{
int maxw = 0;

View File

@ -329,9 +329,9 @@ public:
wxCheckBox * AddCheckBoxOnRight( const wxString &Prompt, bool Selected);
wxComboBox * AddCombo( const wxString &Prompt, const wxString &Selected,const wxArrayStringEx & choices );
wxChoice * AddChoice( const wxString &Prompt,
const wxArrayStringEx &choices, int Selected = -1 );
const TranslatableStrings &choices, int Selected = -1 );
wxChoice * AddChoice( const wxString &Prompt,
const wxArrayStringEx &choices, const wxString &selected );
const TranslatableStrings &choices, const TranslatableString &selected );
wxMenuBar * AddMenuBar( );
wxMenu * AddMenu( const wxString & Title );
void AddIcon( wxBitmap * pBmp);
@ -398,8 +398,10 @@ public:
wxCheckBox * TieCheckBox( const wxString &Prompt, bool & Var );
wxCheckBox * TieCheckBoxOnRight( const wxString & Prompt, bool & Var );
wxChoice * TieChoice( const wxString &Prompt, wxString &Selected, const wxArrayStringEx &choices );
wxChoice * TieChoice( const wxString &Prompt, int &Selected, const wxArrayStringEx &choices );
wxChoice * TieChoice(
const wxString &Prompt, wxString &Selected, const TranslatableStrings &choices );
wxChoice * TieChoice(
const wxString &Prompt, int &Selected, const TranslatableStrings &choices );
wxSlider * TieSlider( const wxString &Prompt, int &pos, const int max, const int min = 0);
wxSlider * TieSlider( const wxString &Prompt, double &pos, const double max, const double min = 0.0);
@ -536,7 +538,9 @@ private:
wxTextCtrl * DoTieTextBox( const wxString &Prompt, WrappedType & WrappedRef, const int nChars);
wxTextCtrl * DoTieNumericTextBox( const wxString &Prompt, WrappedType & WrappedRef, const int nChars);
wxCheckBox * DoTieCheckBox( const wxString &Prompt, WrappedType & WrappedRef );
wxChoice * DoTieChoice( const wxString &Prompt, WrappedType & WrappedRef, const wxArrayStringEx & choices );
wxChoice * DoTieChoice(
const wxString &Prompt, WrappedType & WrappedRef,
const TranslatableStrings & choices );
wxSlider * DoTieSlider( const wxString &Prompt, WrappedType & WrappedRef, const int max, const int min = 0 );
wxSpinCtrl * DoTieSpinCtrl( const wxString &Prompt, WrappedType & WrappedRef, const int max, const int min = 0 );
@ -718,6 +722,7 @@ public:
// Calculate width of a choice control adequate for the items, maybe after
// the dialog is created but the items change.
static void SetMinSize( wxWindow *window, const TranslatableStrings & items );
static void SetMinSize( wxWindow *window, const wxArrayStringEx & items );
// static void SetMinSize( wxWindow *window, const std::vector<int> & items );

View File

@ -972,11 +972,11 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
S.SetStretchyCol( 0 );
m_pTimerAfterCompleteChoiceCtrl = S.AddChoice(_("After Recording completes:"),
{
_("Do nothing") ,
_("Exit Audacity") ,
XO("Do nothing") ,
XO("Exit Audacity") ,
#ifdef __WINDOWS__
_("Restart system") ,
_("Shutdown system") ,
XO("Restart system") ,
XO("Shutdown system") ,
#endif
},
iPostTimerRecordAction

View File

@ -74,7 +74,7 @@ void DragCommand::PopulateOrExchange(ShuttleGui & S)
S.Optional( bHasToX ).TieNumericTextBox( _("To X:"), mToX );
S.Optional( bHasToY ).TieNumericTextBox( _("To Y:"), mToY );
S.Optional( bHasRelativeTo ).TieChoice( _("Relative To:"), mRelativeTo,
LocalizedStrings( kCoordTypeStrings, nCoordTypes ) );
Msgids( kCoordTypeStrings, nCoordTypes ) );
}
S.EndMultiColumn();
}

View File

@ -109,9 +109,9 @@ void GetInfoCommand::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieChoice( _("Type:"),
mInfoType, LocalizedStrings( kTypes, nTypes ));
mInfoType, Msgids( kTypes, nTypes ));
S.TieChoice( _("Format:"),
mFormat, LocalizedStrings( kFormats, nFormats ));
mFormat, Msgids( kFormats, nFormats ));
}
S.EndMultiColumn();
}

View File

@ -51,7 +51,7 @@ void GetTrackInfoCommand::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieChoice( _("Types:"), mInfoType, LocalizedStrings( kTypes, nTypes ));
S.TieChoice( _("Types:"), mInfoType, Msgids( kTypes, nTypes ));
}
S.EndMultiColumn();
}

View File

@ -121,9 +121,9 @@ void ScreenshotCommand::PopulateOrExchange(ShuttleGui & S)
{
S.TieTextBox( _("Path:"), mPath);
S.TieChoice( _("Capture What:"),
mWhat, LocalizedStrings(kCaptureWhatStrings, nCaptureWhats));
mWhat, Msgids(kCaptureWhatStrings, nCaptureWhats));
S.TieChoice( _("Background:"),
mBack, LocalizedStrings(kBackgroundStrings, nBackgrounds));
mBack, Msgids(kBackgroundStrings, nBackgrounds));
S.TieCheckBox( _("Bring To Top:"), mbBringToTop);
}
S.EndMultiColumn();

View File

@ -78,7 +78,7 @@ void SelectTimeCommand::PopulateOrExchange(ShuttleGui & S)
// Chooses what time is relative to.
S.Optional( bHasRelativeSpec ).TieChoice(
_("Relative To:"),
mRelativeTo, LocalizedStrings( kRelativeTo, nRelativeTos ));
mRelativeTo, Msgids( kRelativeTo, nRelativeTos ));
}
S.EndMultiColumn();
}
@ -203,7 +203,7 @@ void SelectTracksCommand::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxALIGN_CENTER);
{
// Always used, so no check box.
S.TieChoice( _("Mode:"), mMode, LocalizedStrings( kModes, nModes ));
S.TieChoice( _("Mode:"), mMode, Msgids( kModes, nModes ));
}
S.EndMultiColumn();
}

View File

@ -63,7 +63,7 @@ void SetClipCommand::PopulateOrExchange(ShuttleGui & S)
{
S.Optional( bHasContainsTime).TieNumericTextBox( _("At:"), mContainsTime );
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour,
LocalizedStrings( kColourStrings, nColours ) );
Msgids( kColourStrings, nColours ) );
S.Optional( bHasT0 ).TieNumericTextBox( _("Start:"), mT0 );
}
S.EndMultiColumn();

View File

@ -317,13 +317,13 @@ void SetTrackVisualsCommand::PopulateOrExchange(ShuttleGui & S)
S.SetStretchyCol( 2 );
S.Optional( bHasHeight ).TieNumericTextBox( _("Height:"), mHeight );
S.Optional( bHasColour ).TieChoice( _("Colour:"), mColour,
LocalizedStrings( kColourStrings, nColours ) );
Msgids( kColourStrings, nColours ) );
S.Optional( bHasDisplayType ).TieChoice( _("Display:"), mDisplayType,
LocalizedStrings( kDisplayTypeStrings, nDisplayTypes ) );
Msgids( kDisplayTypeStrings, nDisplayTypes ) );
S.Optional( bHasScaleType ).TieChoice( _("Scale:"), mScaleType,
LocalizedStrings( kScaleTypeStrings, nScaleTypes ) );
Msgids( kScaleTypeStrings, nScaleTypes ) );
S.Optional( bHasVZoom ).TieChoice( _("VZoom:"), mVZoom,
LocalizedStrings( kZoomTypeStrings, nZoomTypes ) );
Msgids( kZoomTypeStrings, nZoomTypes ) );
S.Optional( bHasVZoomTop ).TieTextBox( _("VZoom Top:"), mVZoomTop );
S.Optional( bHasVZoomBottom ).TieTextBox( _("VZoom Bottom:"), mVZoomBottom );
}

View File

@ -253,9 +253,9 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
{
DeduceFrequencies(); // Set frequency-related control values based on sample.
wxArrayStringEx pitch;
TranslatableStrings pitch;
for (int ii = 0; ii < 12; ++ii)
pitch.push_back( PitchName( ii, PitchNameChoice::Both ).Translation() );
pitch.push_back( PitchName( ii, PitchNameChoice::Both ) );
S.SetBorder(5);

View File

@ -49,12 +49,10 @@ enum kVinyl
kVinyl_33AndAThird = 0,
kVinyl_45,
kVinyl_78,
kVinyl_NA,
nVinyl
kVinyl_NA
};
static const TranslatableString kVinylStrings[nVinyl] =
{
static const TranslatableStrings kVinylStrings{
XO("33\u2153"),
XO("45"),
XO("78"),
@ -296,12 +294,6 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
}
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, mFromVinyl);
wxASSERT(nVinyl == WXSIZEOF(kVinylStrings));
wxArrayStringEx vinylChoices;
for (int i = 0; i < nVinyl; i++)
vinylChoices.push_back(kVinylStrings[i].Translation());
S.SetBorder(5);
S.StartVerticalLay(0);
@ -351,13 +343,13 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
.Name(XO("From rpm"))
.MinSize( { 100, -1 } )
/* i18n-hint: changing a quantity "from" one value "to" another */
.AddChoice(_("from"), vinylChoices);
.AddChoice(_("from"), kVinylStrings);
mpChoice_ToVinyl = S.Id(ID_ToVinyl)
/* i18n-hint: changing a quantity "from" one value "to" another */
.Name(XO("To rpm"))
.MinSize( { 100, -1 } )
.AddChoice(_("to"), vinylChoices);
.AddChoice(_("to"), kVinylStrings);
}
S.EndMultiColumn();

View File

@ -370,7 +370,7 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
.MinSize( { -1, -1 } )
.Validator<wxGenericValidator>(&mParams.mTableChoiceIndx)
.AddChoice(_("Distortion type:"),
LocalizedStrings(kTableTypeStrings, nTableTypes));
Msgids(kTableTypeStrings, nTableTypes));
mDCBlockCheckBox = S.Id(ID_DCBlock).AddCheckBox(_("DC blocking filter"),
DEF_DCBlock);

View File

@ -946,7 +946,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
mInterpChoice = S.Id(ID_Interp)
.Name(XO("Interpolation type"))
.AddChoice( {},
LocalizedStrings(kInterpStrings, nInterpolations), 0 );
Msgids(kInterpStrings, nInterpolations), 0 );
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mInterpChoice->SetAccessible(safenew WindowAccessible(mInterpChoice));
@ -1022,9 +1022,9 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
.Name(XO("Select Curve"))
.AddChoice( {},
[this]{
wxArrayStringEx curves;
TranslatableStrings curves;
for (const auto &curve : mCurves)
curves.push_back(curve.Name);
curves.push_back( Verbatim( curve.Name ) );
return curves;
}()
);

View File

@ -289,7 +289,7 @@ void EffectLoudness::PopulateOrExchange(ShuttleGui & S)
S
.Validator<wxGenericValidator>( &mNormalizeTo )
.AddChoice( {},
LocalizedStrings(kNormalizeTargetStrings, nAlgos),
Msgids(kNormalizeTargetStrings, nAlgos),
mNormalizeTo
);
S.AddVariableText(_("to"), false,

View File

@ -226,7 +226,7 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxCENTER);
{
S.Validator<wxGenericValidator>(&mType)
.AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes));
.AddChoice(_("Noise type:"), Msgids(kTypeStrings, nTypes));
S.Validator<FloatingPointValidator<double>>(
6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES, MIN_Amp, MAX_Amp

View File

@ -466,7 +466,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
.Validator<wxGenericValidator>(&mFilterType)
.MinSize( { -1, -1 } )
.AddChoice(_("&Filter Type:"),
LocalizedStrings(kTypeStrings, nTypes)
Msgids(kTypeStrings, nTypes)
);
mFilterOrderCtl = S.Id(ID_Order)
@ -475,9 +475,9 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
.MinSize( { -1, -1 } )
.AddChoice(_("O&rder:"),
[]{
wxArrayStringEx orders;
TranslatableStrings orders;
for (int i = 1; i <= 10; i++)
orders.push_back(wxString::Format(wxT("%d"), i));
orders.emplace_back( Verbatim("%d").Format( i ) );
return orders;
}()
);
@ -496,7 +496,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
.Validator<wxGenericValidator>(&mFilterSubtype)
.MinSize( { -1, -1 } )
.AddChoice(_("&Subtype:"),
LocalizedStrings(kSubTypeStrings, nSubTypes)
Msgids(kSubTypeStrings, nSubTypes)
);
mCutoffCtl = S.Id(ID_Cutoff)

View File

@ -342,7 +342,7 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
{
S.Validator<wxGenericValidator>(&mWaveform)
.AddChoice(_("Waveform:"),
LocalizedStrings(kWaveStrings, nWaveforms));
Msgids( kWaveStrings, nWaveforms ) );
if (mChirp)
{
@ -423,7 +423,7 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
S.Validator<wxGenericValidator>(&mInterpolation)
.AddChoice(_("Interpolation:"),
LocalizedStrings(kInterStrings, nInterpolations));
Msgids( kInterStrings, nInterpolations ) );
}
else
{

View File

@ -781,7 +781,7 @@ void EffectTruncSilence::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay();
{
// Action choices
auto actionChoices = LocalizedStrings(kActionStrings, nActions);
auto actionChoices = Msgids( kActionStrings, nActions );
mActionChoice = S
.Validator<wxGenericValidator>(&mActionIndex)
.MinSize( { -1, -1 } )

View File

@ -411,7 +411,7 @@ void AudioUnitEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S)
{
S.TieChoice(_("Select &interface"),
mUIType,
{ _("Full"), _("Generic"), _("Basic") });
{ XO("Full"), XO("Generic"), XO("Basic") });
}
S.EndHorizontalLay();
}

View File

@ -2675,7 +2675,7 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
S.AddSpace(10, 10);
S.Id(ID_Choice + i).AddChoice( {},
LocalizedStrings(ctrl.choices.data(), ctrl.choices.size()));
Msgids( ctrl.choices.data(), ctrl.choices.size() ) );
}
else if (ctrl.type == NYQ_CTRL_TIME)
{

View File

@ -570,12 +570,13 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
.Position(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL)
.AddChoice( {},
[&]{
wxArrayStringEx choices;
TranslatableStrings choices;
for (const auto &program : programs)
choices.push_back(wxString::FromUTF8(program.c_str()));
choices.push_back(
Verbatim(wxString::FromUTF8(program.c_str())));
return choices;
}(),
wxString::FromUTF8(mPlugin->getCurrentProgram().c_str())
Verbatim( wxString::FromUTF8(mPlugin->getCurrentProgram().c_str()) )
);
S.AddSpace(1, 1);
@ -626,7 +627,7 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
mParameters[p].quantizeStep == 1.0 &&
!mParameters[p].valueNames.empty())
{
wxArrayStringEx choices;
TranslatableStrings choices;
int selected = -1;
for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++)
@ -636,7 +637,7 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
{
selected = i;
}
choices.push_back(choice);
choices.push_back( Verbatim( choice ) );
}
S.Id(ID_Choices + p);

View File

@ -1066,14 +1066,14 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate,
{
choice = S.AddChoice(_("Sample Rates"),
[&]{
wxArrayStringEx choices;
TranslatableStrings choices;
for (int i = 0; sampRates[i] > 0; i++)
{
int label = sampRates[i];
if (label >= lowrate && label <= highrate)
{
wxString name = wxString::Format(wxT("%d"),label);
choices.push_back(name);
choices.push_back( Verbatim( name ) );
if (label <= rate)
selected = i;
}

View File

@ -2031,11 +2031,11 @@ int ExportMP3::AskResample(int bitrate, int rate, int lowrate, int highrate)
{
choice = S.AddChoice(_("Sample Rates"),
[&]{
wxArrayStringEx choices;
TranslatableStrings choices;
for (size_t ii = 0, nn = sampRates.size(); ii < nn; ++ii) {
int label = sampRates[ii];
if (label >= lowrate && label <= highrate) {
choices.push_back( wxString::Format( "%d", label ) );
choices.push_back( Verbatim( "%d" ).Format( label ) );
if (label <= rate)
selected = ii;
}

View File

@ -115,8 +115,8 @@ private:
private:
wxArrayStringEx mHeaderNames;
wxArrayStringEx mEncodingNames;
TranslatableStrings mHeaderNames;
TranslatableStrings mEncodingNames;
wxChoice *mHeaderChoice;
wxChoice *mEncodingChoice;
int mHeaderFromChoice;
@ -146,7 +146,7 @@ ExportPCMOptions::ExportPCMOptions(wxWindow *parent, int selformat)
mHeaderFromChoice = 0;
for (int i = 0, num = sf_num_headers(); i < num; i++) {
mHeaderNames.push_back(sf_header_index_name(i));
mHeaderNames.push_back( Verbatim( sf_header_index_name(i) ) );
if ((format & SF_FORMAT_TYPEMASK) == (int)sf_header_index_to_type(i))
mHeaderFromChoice = i;
}
@ -158,7 +158,7 @@ ExportPCMOptions::ExportPCMOptions(wxWindow *parent, int selformat)
bool valid = ValidatePair(fmt);
if (valid)
{
mEncodingNames.push_back(sf_encoding_index_name(i));
mEncodingNames.push_back( Verbatim( sf_encoding_index_name(i) ) );
mEncodingFormats.push_back(enc);
if ((format & SF_FORMAT_SUBMASK) == (int)sf_encoding_index_to_subtype(i))
mEncodingFromChoice = sel;
@ -258,7 +258,7 @@ void ExportPCMOptions::OnHeaderChoice(wxCommandEvent & WXUNUSED(evt))
if (valid)
{
const auto name = sf_encoding_index_name(i);
mEncodingNames.push_back(name);
mEncodingNames.push_back( Verbatim( name ) );
mEncodingChoice->Append(name);
mEncodingFormats.push_back(encSubtype);
for (j = 0; j < sfnum; j++)

View File

@ -314,7 +314,7 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
SetName();
ShuttleGui S(this, eIsCreating);
wxArrayStringEx encodings;
TranslatableStrings encodings;
int num;
int selection;
int endian;
@ -337,7 +337,7 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
if (sf_format_check(&info)) {
mEncodingSubtype[mNumEncodings] = subtype;
encodings.push_back(sf_encoding_index_name(i));
encodings.push_back( Verbatim( sf_encoding_index_name(i) ) );
if ((mEncoding & SF_FORMAT_SUBMASK) == subtype)
selection = mNumEncodings;
@ -346,19 +346,19 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
}
}
wxArrayStringEx endians{
TranslatableStrings endians{
/* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
know the correct technical word. */
_("No endianness") ,
XO("No endianness") ,
/* i18n-hint: Refers to byte-order. Don't translate this if you don't
know the correct technical word. */
_("Little-endian") ,
XO("Little-endian") ,
/* i18n-hint: Refers to byte-order. Don't translate this if you don't
know the correct technical word. */
_("Big-endian") ,
XO("Big-endian") ,
/* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
know the correct technical word. */
_("Default endianness") ,
XO("Default endianness") ,
};
switch (mEncoding & (SF_FORMAT_ENDMASK))
@ -378,12 +378,12 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
break;
}
wxArrayStringEx chans{
_("1 Channel (Mono)") ,
_("2 Channels (Stereo)") ,
TranslatableStrings chans{
XO("1 Channel (Mono)") ,
XO("2 Channels (Stereo)") ,
};
for (i=2; i<16; i++) {
chans.push_back(wxString::Format(_("%d Channels"), i + 1));
chans.push_back( XO("%d Channels").Format( i + 1 ) );
}
S.StartVerticalLay(false);

View File

@ -67,8 +67,7 @@ wxString GUIPrefs::HelpPageName()
}
void GUIPrefs::GetRangeChoices(
TranslatableStrings *pChoicesUntranslated,
wxArrayStringEx *pChoicesTranslated,
TranslatableStrings *pChoices,
wxArrayStringEx *pCodes,
int *pDefaultRangeIndex
)
@ -97,13 +96,8 @@ void GUIPrefs::GetRangeChoices(
XO("-145 dB (PCM range of 24 bit samples)") ,
};
if (pChoicesUntranslated)
*pChoicesUntranslated = sChoices;
if (pChoicesTranslated)
*pChoicesTranslated =
transform_container<wxArrayStringEx>( sChoices,
std::mem_fn( &TranslatableString::Translation ) );
if (pChoices)
*pChoices = sChoices;
if (pDefaultRangeIndex)
*pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE
@ -114,7 +108,7 @@ void GUIPrefs::Populate()
// First any pre-processing for constructing the GUI.
GetLanguages(mLangCodes, mLangNames);
GetRangeChoices(&mRangeChoices, nullptr, &mRangeCodes, &mDefaultRangeIndex);
GetRangeChoices(&mRangeChoices, &mRangeCodes, &mDefaultRangeIndex);
#if 0
mLangCodes.insert( mLangCodes.end(), {

View File

@ -36,8 +36,7 @@ class GUIPrefs final : public PrefsPanel
void PopulateOrExchange(ShuttleGui & S) override;
static void GetRangeChoices(
TranslatableStrings *pChoicesUntranslated,
wxArrayStringEx *pChoicesTranslated,
TranslatableStrings *pChoices,
wxArrayStringEx *pCodes,
int *pDefaultRangeIndex = nullptr
);

View File

@ -126,11 +126,11 @@ void ModulePrefs::PopulateOrExchange(ShuttleGui & S)
S.TieChoice( mModules[i],
mStatuses[i],
{
_("Disabled" ) ,
_("Enabled" ) ,
_("Ask" ) ,
_("Failed" ) ,
_("New" ) ,
XO("Disabled" ) ,
XO("Enabled" ) ,
XO("Ask" ) ,
XO("Failed" ) ,
XO("New" ) ,
}
);
S.EndMultiColumn();

View File

@ -112,7 +112,7 @@ void SpectrumPrefs::Populate(size_t windowSize)
PopulatePaddingChoices(windowSize);
for (int i = 0; i < NumWindowFuncs(); i++) {
mTypeChoices.push_back( WindowFuncName(i).Translation() );
mTypeChoices.push_back( WindowFuncName(i) );
}
//------------------------- Main section --------------------
@ -146,8 +146,8 @@ void SpectrumPrefs::PopulatePaddingChoices(size_t windowSize)
int numChoices = 0;
const size_t maxWindowSize = 1 << (SpectrogramSettings::LogMaxWindowSize);
while (windowSize <= maxWindowSize) {
const wxString numeral = wxString::Format(wxT("%d"), padding);
mZeroPaddingChoices.push_back(numeral);
const auto numeral = wxString::Format(wxT("%d"), padding);
mZeroPaddingChoices.push_back( Verbatim( numeral ) );
if (pPaddingSizeControl)
pPaddingSizeControl->Append(numeral);
windowSize <<= 1;
@ -190,9 +190,7 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
S.SetStretchyCol( 1 );
S.Id(ID_SCALE).TieChoice(_("S&cale:"),
mTempSettings.scaleType,
transform_container<wxArrayStringEx>(
SpectrogramSettings::GetScaleNames(),
std::mem_fn( &TranslatableString::Translation ) ) );
SpectrogramSettings::GetScaleNames() );
mMinFreq =
S.Id(ID_MINIMUM).TieNumericTextBox(_("Mi&n Frequency (Hz):"),
mTempSettings.minFreq,
@ -242,26 +240,24 @@ void SpectrumPrefs::PopulateOrExchange(ShuttleGui & S)
mAlgorithmChoice =
S.Id(ID_ALGORITHM).TieChoice(_("A&lgorithm:"),
mTempSettings.algorithm,
transform_container<wxArrayStringEx>(
SpectrogramSettings::GetAlgorithmNames(),
std::mem_fn( &TranslatableString::Translation ) ) );
SpectrogramSettings::GetAlgorithmNames() );
S.Id(ID_WINDOW_SIZE).TieChoice(_("Window &size:"),
mTempSettings.windowSize,
{
_("8 - most wideband"),
_("16"),
_("32"),
_("64"),
_("128"),
_("256"),
_("512"),
_("1024 - default"),
_("2048"),
_("4096"),
_("8192"),
_("16384"),
_("32768 - most narrowband"),
XO("8 - most wideband"),
XO("16"),
XO("32"),
XO("64"),
XO("128"),
XO("256"),
XO("512"),
XO("1024 - default"),
XO("2048"),
XO("4096"),
XO("8192"),
XO("16384"),
XO("32768 - most narrowband"),
}
);

View File

@ -83,10 +83,10 @@ class SpectrumPrefs final : public PrefsPanel
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
int mZeroPaddingChoice;
wxChoice *mZeroPaddingChoiceCtrl;
wxArrayStringEx mZeroPaddingChoices;
TranslatableStrings mZeroPaddingChoices;
#endif
wxArrayStringEx mTypeChoices;
TranslatableStrings mTypeChoices;
wxChoice *mAlgorithmChoice;

View File

@ -79,7 +79,7 @@ enum {
void WaveformPrefs::Populate()
{
// Reuse the same choices and codes as for Interface prefs
GUIPrefs::GetRangeChoices(nullptr, &mRangeChoices, &mRangeCodes);
GUIPrefs::GetRangeChoices(&mRangeChoices, &mRangeCodes);
//------------------------- Main section --------------------
// Now construct the GUI itself.
@ -110,9 +110,7 @@ void WaveformPrefs::PopulateOrExchange(ShuttleGui & S)
mScaleChoice =
S.Id(ID_SCALE).TieChoice(_("S&cale:"),
mTempSettings.scaleType,
transform_container<wxArrayStringEx>(
WaveformSettings::GetScaleNames(),
std::mem_fn( &TranslatableString::Translation ) ) );
WaveformSettings::GetScaleNames() );
mRangeChoice =
S.Id(ID_RANGE).TieChoice(_("Waveform dB &range:"),

View File

@ -56,7 +56,7 @@ private:
wxChoice *mRangeChoice;
wxArrayStringEx mRangeCodes;
wxArrayStringEx mRangeChoices;
TranslatableStrings mRangeChoices;
WaveformSettings mTempSettings;

View File

@ -111,7 +111,7 @@ void WaveformSettings::ConvertToEnumeratedDBRange()
{
// Assumes the codes are in ascending sequence.
wxArrayStringEx codes;
GUIPrefs::GetRangeChoices(nullptr, nullptr, &codes);
GUIPrefs::GetRangeChoices(nullptr, &codes);
int ii = 0;
for (int nn = codes.size(); ii < nn; ++ii) {
long value = 0;
@ -125,7 +125,7 @@ void WaveformSettings::ConvertToEnumeratedDBRange()
void WaveformSettings::ConvertToActualDBRange()
{
wxArrayStringEx codes;
GUIPrefs::GetRangeChoices(nullptr, nullptr, &codes);
GUIPrefs::GetRangeChoices(nullptr, &codes);
long value = 0;
codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]
.ToLong(&value);

View File

@ -846,8 +846,8 @@ void DeviceToolBar::ShowComboDialog(wxChoice *combo, const TranslatableString &t
S.StartHorizontalLay(wxCENTER, false);
{
c = S.AddChoice(combo->GetName(),
inputSources,
combo->GetSelection());
transform_container<TranslatableStrings>( inputSources, Verbatim ),
combo->GetSelection());
}
S.EndHorizontalLay();
}