diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index de8d2f39c..47b15dcf8 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -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" ); diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index c8a0e3970..946d55811 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -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; diff --git a/src/Internat.cpp b/src/Internat.cpp index a09d57bdc..55c1f4114 100644 --- a/src/Internat.cpp +++ b/src/Internat.cpp @@ -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( + return transform_range( strings, strings + nStrings, - std::mem_fn( &EnumValueSymbol::Translation ) + std::mem_fn( &EnumValueSymbol::Msgid ) ); } diff --git a/src/Internat.h b/src/Internat.h index dae3ca871..07131d664 100644 --- a/src/Internat.h +++ b/src/Internat.h @@ -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 diff --git a/src/LangChoice.cpp b/src/LangChoice.cpp index 92605c759..bbb9d1ba3 100644 --- a/src/LangChoice.cpp +++ b/src/LangChoice.cpp @@ -87,10 +87,7 @@ LangChoiceDialog::LangChoiceDialog(wxWindow * parent, { S.SetBorder(15); mChoice = S.AddChoice(_("Choose Language for Audacity to use:"), - transform_container(mLangNames, - // Using MSGID until AddChoice is rewritten to take - // TranslatableStrings directly - [](const TranslatableString &str){ return str.MSGID().GET(); }), + mLangNames, lang); } S.EndVerticalLay(); diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 903928132..3d28869cd 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -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( *this, - std::mem_fn( &EnumValueSymbol::Translation ) ); - return mTranslations; + if ( mMsgids.empty() ) + mMsgids = transform_container( *this, + std::mem_fn( &EnumValueSymbol::Msgid ) ); + return mMsgids; } const wxArrayStringEx &EnumValueSymbols::GetInternals() const diff --git a/src/Prefs.h b/src/Prefs.h index b032b11f6..72c9acbb4 100644 --- a/src/Prefs.h +++ b/src/Prefs.h @@ -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; }; diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index acfe18a96..2e32f0074 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -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( + 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(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( + items, std::mem_fn( &TranslatableString::Translation ) ) ); +} + void ShuttleGui::SetMinSize( wxWindow *window, const wxArrayStringEx & items ) { int maxw = 0; diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index 4e54c1923..d9c851f8f 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -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 & items ); diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 487e853ea..93eef1c49 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -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 diff --git a/src/commands/DragCommand.cpp b/src/commands/DragCommand.cpp index 55e3fe864..0ae6e8e98 100644 --- a/src/commands/DragCommand.cpp +++ b/src/commands/DragCommand.cpp @@ -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(); } diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index 64c6909f7..42832ac06 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -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(); } diff --git a/src/commands/GetTrackInfoCommand.cpp b/src/commands/GetTrackInfoCommand.cpp index 56a7057b8..84dd00a27 100644 --- a/src/commands/GetTrackInfoCommand.cpp +++ b/src/commands/GetTrackInfoCommand.cpp @@ -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(); } diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index 5fa8fd607..37f20fa4c 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -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(); diff --git a/src/commands/SelectCommand.cpp b/src/commands/SelectCommand.cpp index e81dade04..ff0c7475f 100644 --- a/src/commands/SelectCommand.cpp +++ b/src/commands/SelectCommand.cpp @@ -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(); } diff --git a/src/commands/SetClipCommand.cpp b/src/commands/SetClipCommand.cpp index fc0077996..188732fb6 100644 --- a/src/commands/SetClipCommand.cpp +++ b/src/commands/SetClipCommand.cpp @@ -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(); diff --git a/src/commands/SetTrackInfoCommand.cpp b/src/commands/SetTrackInfoCommand.cpp index 1a20b0239..2146ebcda 100644 --- a/src/commands/SetTrackInfoCommand.cpp +++ b/src/commands/SetTrackInfoCommand.cpp @@ -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 ); } diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index 9bf0e5c6b..65bfd1e8b 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -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); diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index a5d286b1a..98c027377 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -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(); diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index f34b5fd75..3817f3512 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -370,7 +370,7 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S) .MinSize( { -1, -1 } ) .Validator(&mParams.mTableChoiceIndx) .AddChoice(_("Distortion type:"), - LocalizedStrings(kTableTypeStrings, nTableTypes)); + Msgids(kTableTypeStrings, nTableTypes)); mDCBlockCheckBox = S.Id(ID_DCBlock).AddCheckBox(_("DC blocking filter"), DEF_DCBlock); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index d6f9273dd..d8f04c596 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -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; }() ); diff --git a/src/effects/Loudness.cpp b/src/effects/Loudness.cpp index 20b1d85f2..dab405421 100644 --- a/src/effects/Loudness.cpp +++ b/src/effects/Loudness.cpp @@ -289,7 +289,7 @@ void EffectLoudness::PopulateOrExchange(ShuttleGui & S) S .Validator( &mNormalizeTo ) .AddChoice( {}, - LocalizedStrings(kNormalizeTargetStrings, nAlgos), + Msgids(kNormalizeTargetStrings, nAlgos), mNormalizeTo ); S.AddVariableText(_("to"), false, diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index b70212a82..0c8af6c53 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -226,7 +226,7 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S) S.StartMultiColumn(2, wxCENTER); { S.Validator(&mType) - .AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes)); + .AddChoice(_("Noise type:"), Msgids(kTypeStrings, nTypes)); S.Validator>( 6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES, MIN_Amp, MAX_Amp diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 3ab8d3dfc..7ebf515a6 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -466,7 +466,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) .Validator(&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(&mFilterSubtype) .MinSize( { -1, -1 } ) .AddChoice(_("&Subtype:"), - LocalizedStrings(kSubTypeStrings, nSubTypes) + Msgids(kSubTypeStrings, nSubTypes) ); mCutoffCtl = S.Id(ID_Cutoff) diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index 55c40810b..ec46b3142 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -342,7 +342,7 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) { S.Validator(&mWaveform) .AddChoice(_("Waveform:"), - LocalizedStrings(kWaveStrings, nWaveforms)); + Msgids( kWaveStrings, nWaveforms ) ); if (mChirp) { @@ -423,7 +423,7 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) S.Validator(&mInterpolation) .AddChoice(_("Interpolation:"), - LocalizedStrings(kInterStrings, nInterpolations)); + Msgids( kInterStrings, nInterpolations ) ); } else { diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index 7502c50ca..1206951cf 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -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(&mActionIndex) .MinSize( { -1, -1 } ) diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 73ca66333..ba406da0c 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -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(); } diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 10a7f3aa0..57af8a448 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -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) { diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index c53cb3163..81d0644a9 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -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); diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index c2bc81f68..451667ae2 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -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; } diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index b89f12398..16051398a 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -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; } diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 19c9f6d69..e20c46ea3 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -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++) diff --git a/src/import/ImportRaw.cpp b/src/import/ImportRaw.cpp index 6405e1070..38bddecb7 100644 --- a/src/import/ImportRaw.cpp +++ b/src/import/ImportRaw.cpp @@ -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); diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index 879df7a6b..45fae7d65 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -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( 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(), { diff --git a/src/prefs/GUIPrefs.h b/src/prefs/GUIPrefs.h index 4e87e65c9..3dfcc8789 100644 --- a/src/prefs/GUIPrefs.h +++ b/src/prefs/GUIPrefs.h @@ -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 ); diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index 3d94a451d..183c9b214 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -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(); diff --git a/src/prefs/SpectrumPrefs.cpp b/src/prefs/SpectrumPrefs.cpp index 862eeb42b..1c80a8bf2 100644 --- a/src/prefs/SpectrumPrefs.cpp +++ b/src/prefs/SpectrumPrefs.cpp @@ -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( - 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( - 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"), } ); diff --git a/src/prefs/SpectrumPrefs.h b/src/prefs/SpectrumPrefs.h index bdb11d2d8..4172d7026 100644 --- a/src/prefs/SpectrumPrefs.h +++ b/src/prefs/SpectrumPrefs.h @@ -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; diff --git a/src/prefs/WaveformPrefs.cpp b/src/prefs/WaveformPrefs.cpp index 25284fc7b..2b7db2c77 100644 --- a/src/prefs/WaveformPrefs.cpp +++ b/src/prefs/WaveformPrefs.cpp @@ -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( - WaveformSettings::GetScaleNames(), - std::mem_fn( &TranslatableString::Translation ) ) ); + WaveformSettings::GetScaleNames() ); mRangeChoice = S.Id(ID_RANGE).TieChoice(_("Waveform dB &range:"), diff --git a/src/prefs/WaveformPrefs.h b/src/prefs/WaveformPrefs.h index 55177b241..1788220b0 100644 --- a/src/prefs/WaveformPrefs.h +++ b/src/prefs/WaveformPrefs.h @@ -56,7 +56,7 @@ private: wxChoice *mRangeChoice; wxArrayStringEx mRangeCodes; - wxArrayStringEx mRangeChoices; + TranslatableStrings mRangeChoices; WaveformSettings mTempSettings; diff --git a/src/prefs/WaveformSettings.cpp b/src/prefs/WaveformSettings.cpp index 52a02030b..1b1be10b2 100644 --- a/src/prefs/WaveformSettings.cpp +++ b/src/prefs/WaveformSettings.cpp @@ -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); diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 1e76c1de3..f24ed2fe8 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -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( inputSources, Verbatim ), + combo->GetSelection()); } S.EndHorizontalLay(); }