diff --git a/include/audacity/ComponentInterface.h b/include/audacity/ComponentInterface.h index 15c4934d0..f96c07db0 100644 --- a/include/audacity/ComponentInterface.h +++ b/include/audacity/ComponentInterface.h @@ -62,11 +62,16 @@ public: ComponentInterfaceSymbol() = default; // Allows implicit construction from a msgid re-used as an internal string - ComponentInterfaceSymbol( const wxString &msgid ) - : mInternal{ msgid }, mMsgid{ msgid } + ComponentInterfaceSymbol( const TranslatableString &msgid ) + : mInternal{ msgid.MSGID().GET(), }, mMsgid{ msgid } {} - // Allows implicit construction from a msgid re-used as an internal string + // Allows implicit construction from an internal string re-used as a msgid + ComponentInterfaceSymbol( const wxString &internal ) + : mInternal{ internal }, mMsgid{ internal } + {} + + // Allows implicit construction from an internal string re-used as a msgid ComponentInterfaceSymbol( const wxChar *msgid ) : mInternal{ msgid }, mMsgid{ msgid } {} @@ -82,8 +87,7 @@ public: const wxString &Internal() const { return mInternal; } const TranslatableString &Msgid() const { return mMsgid; } - const wxString &Translation() const - { return GetCustomTranslation( mMsgid ); } + const wxString &Translation() const { return mMsgid.Translation(); } bool empty() const { return mInternal.empty(); } diff --git a/include/audacity/Types.h b/include/audacity/Types.h index 0103e4325..f11816d84 100644 --- a/include/audacity/Types.h +++ b/include/audacity/Types.h @@ -299,7 +299,8 @@ using CommandIDs = std::vector; // the user-visible translation. The msgid should be used only in unusual cases // and the translation more often // -class TranslatableString : public wxString { +// Implicit conversions to and from wxString are intentionally disabled +class TranslatableString : private wxString { public: TranslatableString() {} diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 60bc1bcda..ebe3f88d0 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -56,7 +56,7 @@ enum eCommandType { CtEffect, CtMenu, CtSpecial }; // TIDY-ME: Not currently translated, // but there are issues to address if we do. // CLEANSPEECH remnant -static const std::pair SpecialCommands[] = { +static const std::pair SpecialCommands[] = { // Use translations of the first members, some other day. // For 2.2.2 we'll get them into the catalog at least. @@ -103,16 +103,16 @@ MacroCommands::MacroCommands() } } -static const wxString MP3Conversion = XO("MP3 Conversion"); -static const wxString FadeEnds = XO("Fade Ends"); -static const wxString SelectToEnds = XO("Select to Ends"); +static const auto MP3Conversion = XO("MP3 Conversion"); +static const auto FadeEnds = XO("Fade Ends"); +static const auto SelectToEnds = XO("Select to Ends"); wxArrayStringEx MacroCommands::GetNamesOfDefaultMacros() { return { - GetCustomTranslation( MP3Conversion ) , - GetCustomTranslation( FadeEnds ) , + MP3Conversion.Translation() , + FadeEnds.Translation() , //Don't add this one anymore, as there is a new menu command for it. //GetCustomTranslation( SelectToEnds ) , }; @@ -123,16 +123,16 @@ void MacroCommands::RestoreMacro(const wxString & name) // TIDY-ME: Effects change their name with localisation. // Commands (at least currently) don't. Messy. ResetMacro(); - if (name == GetCustomTranslation( MP3Conversion ) ){ + if (name == MP3Conversion.Translation() ){ AddToMacro( wxT("Normalize") ); AddToMacro( wxT("ExportMP3") ); - } else if (name == GetCustomTranslation( FadeEnds ) ){ + } else if (name == FadeEnds.Translation() ){ AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\"") ); AddToMacro( wxT("FadeIn") ); AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\" RelativeTo=\"ProjectEnd\"") ); AddToMacro( wxT("FadeOut") ); AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"0\"") ); - } else if (name == GetCustomTranslation( SelectToEnds ) ){ + } else if (name == SelectToEnds.Translation() ){ AddToMacro( wxT("SelCursorEnd") ); AddToMacro( wxT("SelStartCursor") ); } @@ -294,7 +294,7 @@ MacroCommandsCatalog::MacroCommandsCatalog( const AudacityProject *project ) Entries commands; for( const auto &command : SpecialCommands ) commands.push_back( { - { command.second, GetCustomTranslation( command.first ) }, + { command.second, command.first.Translation() }, _("Special Command") } ); diff --git a/src/LangChoice.cpp b/src/LangChoice.cpp index 10dadd792..f6fd9060b 100644 --- a/src/LangChoice.cpp +++ b/src/LangChoice.cpp @@ -119,7 +119,7 @@ void LangChoiceDialog::OnOk(wxCommandEvent & WXUNUSED(event)) } } else { - sname = mLangNames[sndx]; + sname = mLangNames[sndx].Translation(); } if (mLang.Left(2) != slang.Left(2)) { diff --git a/src/Languages.cpp b/src/Languages.cpp index be6ec9007..d4159c94e 100644 --- a/src/Languages.cpp +++ b/src/Languages.cpp @@ -293,7 +293,10 @@ void GetLanguages( reverseHash[tempNames[j]] = tempCodes[j]; } - std::sort( tempNames.begin(), tempNames.end() ); + std::sort( tempNames.begin(), tempNames.end(), + []( const TranslatableString &a, const TranslatableString &b ){ + return a.Translation() < b.Translation(); + } ); // Add system language langNames.push_back(XO("System")); diff --git a/src/Menus.cpp b/src/Menus.cpp index 138cd3487..f61fad40a 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -738,7 +738,7 @@ void MenuManager::TellUserWhyDisallowed( return; // Message is already translated but title is not yet - auto title = ::GetCustomTranslation( untranslatedTitle ); + auto title = untranslatedTitle.Translation(); // Does not have the warning icon... ShowErrorDialog( diff --git a/src/PitchName.cpp b/src/PitchName.cpp index de83098fa..72df476c3 100644 --- a/src/PitchName.cpp +++ b/src/PitchName.cpp @@ -59,7 +59,7 @@ int PitchOctave(const double dMIDInote) wxString PitchName(const double dMIDInote, const PitchNameChoice choice) { - static const wxString sharpnames[12] = { + static const TranslatableString sharpnames[12] = { /* i18n-hint: Name of a musical note in the 12-tone chromatic scale */ XO("C"), /* i18n-hint: Name of a musical note in the 12-tone chromatic scale */ @@ -86,7 +86,7 @@ wxString PitchName(const double dMIDInote, const PitchNameChoice choice) XO("B"), }; - static const wxString flatnames[12] = { + static const TranslatableString flatnames[12] = { /* i18n-hint: Name of a musical note in the 12-tone chromatic scale */ XO("C"), /* i18n-hint: Name of a musical note in the 12-tone chromatic scale */ @@ -113,7 +113,7 @@ wxString PitchName(const double dMIDInote, const PitchNameChoice choice) XO("B"), }; - static const wxString bothnames[12] = { + static const TranslatableString bothnames[12] = { /* i18n-hint: Name of a musical note in the 12-tone chromatic scale */ XO("C"), /* i18n-hint: Two, alternate names of a musical note in the 12-tone chromatic scale */ @@ -140,7 +140,7 @@ wxString PitchName(const double dMIDInote, const PitchNameChoice choice) XO("B"), }; - const wxString *table = nullptr; + const TranslatableString *table = nullptr; switch ( choice ) { case PitchNameChoice::Sharps: table = sharpnames; break; case PitchNameChoice::Flats: table = flatnames; break; @@ -148,7 +148,7 @@ wxString PitchName(const double dMIDInote, const PitchNameChoice choice) default: wxASSERT(false); break; } - return GetCustomTranslation( table[PitchIndex(dMIDInote)] ); + return table[PitchIndex(dMIDInote)].Translation(); } wxString PitchName_Absolute(const double dMIDInote, const PitchNameChoice choice) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index d4a9ad6f8..e3179aa56 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -2307,7 +2307,7 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) // PRL: Writing KEY_NAME which is no longer read, but older Audacity // versions expect to find it. - pRegistry->Write(KEY_NAME, plug.GetSymbol().Msgid()); + pRegistry->Write(KEY_NAME, plug.GetSymbol().Msgid().MSGID()); pRegistry->Write(KEY_VERSION, plug.GetUntranslatedVersion()); pRegistry->Write(KEY_VENDOR, plug.GetVendor()); diff --git a/src/Tags.cpp b/src/Tags.cpp index 2339e9d84..b892fc55e 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -753,7 +753,7 @@ static wxArrayString names() void Populate() override { for (auto &name : theNames) - mContents.push_back( wxGetTranslation( name ) ); + mContents.push_back( name.Translation() ); } }; @@ -999,7 +999,7 @@ bool TagsEditor::TransferDataFromWindow() for (i = 0; i < cnt; i++) { // Get tag name from the grid - wxString n = mGrid->GetCellValue(i, 0); + auto n = mGrid->GetCellValue(i, 0); wxString v = mGrid->GetCellValue(i, 1); if (n.empty()) { @@ -1009,25 +1009,25 @@ bool TagsEditor::TransferDataFromWindow() bool bSpecialTag = true; // Map special tag names back to internal keys - if (n.CmpNoCase(wxGetTranslation(LABEL_ARTIST)) == 0) { + if (n.CmpNoCase(LABEL_ARTIST.Translation()) == 0) { n = TAG_ARTIST; } - else if (n.CmpNoCase(wxGetTranslation(LABEL_TITLE)) == 0) { + else if (n.CmpNoCase(LABEL_TITLE.Translation()) == 0) { n = TAG_TITLE; } - else if (n.CmpNoCase(wxGetTranslation(LABEL_ALBUM)) == 0) { + else if (n.CmpNoCase(LABEL_ALBUM.Translation()) == 0) { n = TAG_ALBUM; } - else if (n.CmpNoCase(wxGetTranslation(LABEL_TRACK)) == 0) { + else if (n.CmpNoCase(LABEL_TRACK.Translation()) == 0) { n = TAG_TRACK; } - else if (n.CmpNoCase(wxGetTranslation(LABEL_YEAR)) == 0) { + else if (n.CmpNoCase(LABEL_YEAR.Translation()) == 0) { n = TAG_YEAR; } - else if (n.CmpNoCase(wxGetTranslation(LABEL_GENRE)) == 0) { + else if (n.CmpNoCase(LABEL_GENRE.Translation()) == 0) { n = TAG_GENRE; } - else if (n.CmpNoCase(wxGetTranslation(LABEL_COMMENTS)) == 0) { + else if (n.CmpNoCase(LABEL_COMMENTS.Translation()) == 0) { n = TAG_COMMENTS; } else { @@ -1060,16 +1060,16 @@ bool TagsEditor::TransferDataToWindow() mGrid->SetReadOnly(i, 0); // The special tag name that's displayed and translated may not match // the key string used for internal lookup. - mGrid->SetCellValue(i, 0, wxGetTranslation( labelmap[i].label ) ); + mGrid->SetCellValue(i, 0, labelmap[i].label.Translation() ); mGrid->SetCellValue(i, 1, mLocal.GetTag(labelmap[i].name)); if (!mEditTitle && - mGrid->GetCellValue(i, 0).CmpNoCase(wxGetTranslation(LABEL_TITLE)) == 0) { + mGrid->GetCellValue(i, 0).CmpNoCase(LABEL_TITLE.Translation()) == 0) { mGrid->SetReadOnly(i, 1); } if (!mEditTrack && - mGrid->GetCellValue(i, 0).CmpNoCase(wxGetTranslation(LABEL_TRACK)) == 0) { + mGrid->GetCellValue(i, 0).CmpNoCase(LABEL_TRACK.Translation()) == 0) { mGrid->SetReadOnly(i, 1); } @@ -1399,12 +1399,12 @@ void TagsEditor::OnRemove(wxCommandEvent & WXUNUSED(event)) size_t row = mGrid->GetGridCursorRow(); if (!mEditTitle && - mGrid->GetCellValue(row, 0).CmpNoCase(wxGetTranslation(LABEL_TITLE)) == 0) { + mGrid->GetCellValue(row, 0).CmpNoCase(LABEL_TITLE.Translation()) == 0) { return; } else if (!mEditTrack && mGrid->GetCellValue(row, 0) - .CmpNoCase(wxGetTranslation(LABEL_TRACK)) == 0) { + .CmpNoCase(LABEL_TRACK.Translation()) == 0) { return; } else if (row < STATICCNT) { @@ -1478,7 +1478,7 @@ void TagsEditor::SetEditors() for (int i = 0; i < cnt; i++) { wxString label = mGrid->GetCellValue(i, 0); - if (label.CmpNoCase(wxGetTranslation(LABEL_GENRE)) == 0) { + if (label.CmpNoCase(LABEL_GENRE.Translation()) == 0) { // This use of GetDefaultEditorForType does not require DecRef. mGrid->SetCellEditor(i, 1, mGrid->GetDefaultEditorForType(wxT("Combo"))); } diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index 0df8cfa24..1e67f9734 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -270,6 +270,7 @@ bool CommandImplementation::SetParameter(const wxString ¶mName, const wxVari context.Error( wxString::Format( _("%s is not a parameter accepted by %s"), paramName, GetSymbol().Internal() ) ); + // neglect translation for scripting ?? return false; } diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index 9dc664519..a60f4ab41 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -300,16 +300,7 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) wxArrayStringEx vinylChoices; for (int i = 0; i < nVinyl; i++) - { - if (i == kVinyl_NA) - { - vinylChoices.push_back(wxGetTranslation(kVinylStrings[i])); - } - else - { - vinylChoices.push_back(kVinylStrings[i]); - } - } + vinylChoices.push_back(kVinylStrings[i].Translation()); S.SetBorder(5); diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index 8a068fd56..7cb8f5b97 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -144,7 +144,7 @@ wxString defaultLabel(int index) void Populate() override { for (auto &name : names) - mContents.push_back( wxGetTranslation( name ) ); + mContents.push_back( name.Translation() ); } }; @@ -338,7 +338,7 @@ RegistryPaths EffectDistortion::GetFactoryPresets() for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) { - names.push_back(wxGetTranslation(FactoryPresets[i].name)); + names.push_back( FactoryPresets[i].name.Translation() ); } return names; diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 97be563b0..0acb03a16 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -428,7 +428,7 @@ bool EffectEqualization::LoadFactoryDefaults() static const struct { - const wxChar *name; + const TranslatableString name; const wxChar *values; } FactoryPresets[] = @@ -463,7 +463,7 @@ RegistryPaths EffectEqualization::GetFactoryPresets() for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) { - names.push_back(wxGetTranslation(FactoryPresets[i].name)); + names.push_back(FactoryPresets[i].name.Translation()); } return names; diff --git a/src/effects/Reverb.cpp b/src/effects/Reverb.cpp index 258f2769e..de8266a60 100644 --- a/src/effects/Reverb.cpp +++ b/src/effects/Reverb.cpp @@ -335,7 +335,7 @@ RegistryPaths EffectReverb::GetFactoryPresets() for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) { - names.push_back(wxGetTranslation(FactoryPresets[i].name)); + names.push_back( FactoryPresets[i].name.Translation() ); } return names; diff --git a/src/effects/SBSMSEffect.h b/src/effects/SBSMSEffect.h index cd000d79b..784818dfb 100644 --- a/src/effects/SBSMSEffect.h +++ b/src/effects/SBSMSEffect.h @@ -37,7 +37,7 @@ public: static double getRate(double rateStart, double rateEnd, SlideType slideType, double t); protected: - wxString mProxyEffectName { XO("SBSMS Time / Pitch Stretch") }; + TranslatableString mProxyEffectName { XO("SBSMS Time / Pitch Stretch") }; // This supplies the abstract virtual function, but in fact this symbol // does not get used: this class is either a temporary helper, or else // GetSymbol() is overridden further in derived classes. diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 7ab1bab47..decce5839 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -344,7 +344,7 @@ VendorSymbol LV2Effect::GetVendor() if (vendor.empty()) { - vendor = XO("n/a"); + return XO("n/a"); } return { vendor }; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index bcf27ef85..52eddd38f 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -186,7 +186,7 @@ NyquistEffect::NyquistEffect(const wxString &fName) } mFileName = fName; - mName = mFileName.GetName(); + mName = TranslatableString{ mFileName.GetName() }; mFileModified = mFileName.GetModificationTime(); ParseFile(); @@ -228,12 +228,15 @@ VendorSymbol NyquistEffect::GetVendor() wxString NyquistEffect::GetVersion() { - return mReleaseVersion; + // Are Nyquist version strings really supposed to be translatable? + // See commit a06e561 which used XO for at least one of them + return mReleaseVersion.Translation(); } wxString NyquistEffect::GetDescription() { - return mCopyright; + // This should be a translated string, consistent with other effects + return mCopyright.Translation(); } wxString NyquistEffect::ManualPage() @@ -924,7 +927,7 @@ finish: if (mDebug && !mRedirectOutput) { NyquistOutputDialog dlog(mUIParent, -1, - mName, + mName.Translation(), _("Debug Output: "), mDebugOutput); dlog.CentreOnParent(); @@ -1333,7 +1336,7 @@ bool NyquistEffect::ProcessOne() // If we're not showing debug window, log errors and warnings: if (!mDebugOutput.empty() && !mDebug && !mTrace) { /* i18n-hint: An effect "returned" a message.*/ - wxLogMessage(_("\'%s\' returned:\n%s"), mName, mDebugOutput); + wxLogMessage(_("\'%s\' returned:\n%s"), mName.Translation(), mDebugOutput); } // Audacity has no idea how long Nyquist processing will take, but @@ -1368,8 +1371,10 @@ bool NyquistEffect::ProcessOne() // Show error in debug window if trace enabled, otherwise log. if (mTrace) { /* i18n-hint: "%s" is replaced by name of plug-in.*/ - mDebugOutput = wxString::Format(_("nyx_error returned from %s.\n"), - mName.empty()? _("plug-in") : mName) + mDebugOutput; + mDebugOutput = wxString::Format( + _("nyx_error returned from %s.\n"), + mName.empty()? _("plug-in") : mName.Translation() + ) + mDebugOutput; mDebug = true; } else { @@ -1878,14 +1883,15 @@ bool NyquistEffect::Parse( } if (len >= 2 && tokens[0] == wxT("name")) { - mName = UnQuote(tokens[1]); + auto name = UnQuote(tokens[1]); // Strip ... from name if it's present, perhaps in third party plug-ins // Menu system puts ... back if there are any controls // This redundant naming convention must NOT be followed for // shipped Nyquist effects with internationalization. Else the msgid // later looked up will lack the ... and will not be found. - if (mName.EndsWith(wxT("..."))) - mName = mName.RemoveLast(3); + if (name.EndsWith(wxT("..."))) + name = name.RemoveLast(3); + mName = TranslatableString{ name }; return true; } diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index cb5d5202d..1ef2668b7 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -213,8 +213,8 @@ private: wxString mInitError; wxString mInputCmd; // history: exactly what the user typed wxString mCmd; // the command to be processed - wxString mName; ///< Name of the Effect (untranslated) - wxString mPromptName; // If a prompt, we need to remember original name. + TranslatableString mName; ///< Name of the Effect (untranslated) + TranslatableString mPromptName; // If a prompt, we need to remember original name. TranslatableString mAction; TranslatableString mInfo; TranslatableString mAuthor; diff --git a/src/export/Export.cpp b/src/export/Export.cpp index fef54cfdd..5f652cd76 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -160,7 +160,7 @@ TranslatableString ExportPlugin::GetUntranslatedDescription(int index) wxString ExportPlugin::GetTranslatedDescription(int index) { - return GetCustomTranslation( GetUntranslatedDescription( index ) ); + return GetUntranslatedDescription( index ).Translation(); } FileExtension ExportPlugin::GetExtension(int index) diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 480cd12e0..56d67e58d 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -536,7 +536,7 @@ void ExportMP3Options::LoadNames(const TranslatableStrings &names) { mRate->Clear(); for (const auto &name : names) - mRate->Append( GetCustomTranslation( name ) ); + mRate->Append( name.Translation() ); } //---------------------------------------------------------------------------- diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index 59e60baea..9b1c791d9 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -187,6 +187,18 @@ void AddEffectMenuItemGroup( const std::vector & flags, bool isDefault); +namespace +{ + +inline bool HasDialog( const PluginDescriptor *plug ) +{ + // Un-translated string is expected to follow a certain convention + // Translation, perhaps, uses some other punctuation + return plug->GetSymbol().Msgid().MSGID().GET().Contains("..."); +} + +} + void AddEffectMenuItems( MenuTable::BaseItemPtrs &table, std::vector & plugs, @@ -207,7 +219,7 @@ void AddEffectMenuItems( // Some weird special case stuff just for Noise Reduction so that there is // more informative help const auto getBatchFlags = [&]( const PluginDescriptor *plug ){ - if ( plug->GetSymbol().Msgid() == wxT( "Noise Reduction" ) ) + if ( plug->GetSymbol().Msgid() == XO( "Noise Reduction" ) ) return ( batchflags | NoiseReductionTimeSelectedFlag ) & ~TimeSelectedFlag; return batchflags; @@ -226,7 +238,7 @@ void AddEffectMenuItems( { const PluginDescriptor *plug = plugs[i]; - bool hasDialog = plug->GetSymbol().Msgid().Contains("..."); + bool hasDialog = HasDialog( plug ); auto name = plug->GetSymbol().Translation(); if (plug->IsEffectInteractive()) @@ -299,7 +311,7 @@ void AddEffectMenuItems( { const PluginDescriptor *plug = plugs[i]; - bool hasDialog = plug->GetSymbol().Msgid().Contains("..."); + bool hasDialog = HasDialog( plug ); auto name = plug->GetSymbol().Translation(); if (plug->IsEffectInteractive()) diff --git a/src/prefs/DevicePrefs.cpp b/src/prefs/DevicePrefs.cpp index caad2c20e..a0af2e8b8 100644 --- a/src/prefs/DevicePrefs.cpp +++ b/src/prefs/DevicePrefs.cpp @@ -115,7 +115,7 @@ void DevicePrefs::GetNamesAndLabels() const PaDeviceInfo *info = Pa_GetDeviceInfo(i); if ((info!=NULL)&&(info->maxOutputChannels > 0 || info->maxInputChannels > 0)) { wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name); - if ( ! make_iterator_range( mHostNames ).contains( name ) ) { + if (!make_iterator_range(mHostNames).contains(TranslatableString{name})) { mHostNames.push_back( TranslatableString{ name } ); mHostLabels.push_back(name); } @@ -214,7 +214,7 @@ void DevicePrefs::OnHost(wxCommandEvent & e) // Find the index for the host API selected int index = -1; - wxString apiName = mHostNames[mHost->GetCurrentSelection()]; + auto apiName = mHostLabels[mHost->GetCurrentSelection()]; int nHosts = Pa_GetHostApiCount(); for (int i = 0; i < nHosts; ++i) { wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(i)->name); diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index 8395384c5..f293b2842 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -99,7 +99,7 @@ namespace { // It is not required that each module be found here, nor that each module // mentioned here be found. -const std::map< wxString, wxString > SuggestedPrompts{ +const std::map< wxString, TranslatableString > SuggestedPrompts{ /* i18n-hint: Audio Unit is the name of an Apple audio software protocol */ { wxT("AudioUnit"), XO("Audio Unit") }, @@ -131,7 +131,7 @@ const std::map< wxString, wxString > SuggestedPrompts{ // Collect needed prompts and settings paths, at most once, on demand struct Entry { - wxString prompt; // untranslated + TranslatableString prompt; wxString setting; }; static const std::vector< Entry > &GetModuleData() @@ -146,7 +146,7 @@ static const std::vector< Entry > &GetModuleData() if ( internal.empty() ) continue; - wxString prompt; + TranslatableString prompt; auto iter = SuggestedPrompts.find( internal ); if ( iter == SuggestedPrompts.end() ) // For the built-in modules this Msgid includes " Effects", @@ -187,7 +187,7 @@ void EffectsPrefs::PopulateOrExchange(ShuttleGui & S) for ( const auto &entry : GetModuleData() ) { S.TieCheckBox( - GetCustomTranslation( entry.prompt ), + entry.prompt.Translation(), {entry.setting, true} ); diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index d982a3657..9016dd86d 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -102,7 +102,8 @@ void GUIPrefs::GetRangeChoices( if (pChoicesTranslated) *pChoicesTranslated = - transform_container( sChoices, GetCustomTranslation ); + transform_container( sChoices, + std::mem_fn( &TranslatableString::Translation ) ); if (pDefaultRangeIndex) *pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE diff --git a/src/prefs/MidiIOPrefs.cpp b/src/prefs/MidiIOPrefs.cpp index 25d6ae1b5..d97e8413d 100644 --- a/src/prefs/MidiIOPrefs.cpp +++ b/src/prefs/MidiIOPrefs.cpp @@ -119,7 +119,7 @@ void MidiIOPrefs::GetNamesAndLabels() { const PmDeviceInfo *info = Pm_GetDeviceInfo(i); if (info->output || info->input) { //should always happen wxString name = wxSafeConvertMB2WX(info->interf); - if ( ! make_iterator_range( mHostNames ).contains( name ) ) { + if (!make_iterator_range(mHostNames).contains(TranslatableString{name})) { mHostNames.push_back( TranslatableString{ name } ); mHostLabels.push_back(name); } @@ -194,7 +194,7 @@ void MidiIOPrefs::OnHost(wxCommandEvent & WXUNUSED(e)) wxString itemAtIndex; int index = mHost->GetCurrentSelection(); if (index >= 0 && index < (int)mHostNames.size()) - itemAtIndex = mHostNames[index]; + itemAtIndex = mHostLabels[index]; int nDevices = Pm_CountDevices(); if (nDevices == 0) { diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index a79ae23f8..51bd79b85 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -687,14 +687,14 @@ registeredStatusWidthFunction{ -> ProjectStatus::StatusWidthResult { if ( field == stateStatusBarField ) { - const auto pauseString = wxT(" ") + GetCustomTranslation(sStatePause); + const auto pauseString = wxT(" ") + sStatePause.Translation(); std::vector strings; for ( auto pString : { &sStatePlay, &sStateStop, &sStateRecord } ) { strings.push_back( - GetCustomTranslation(*pString) + pauseString + wxT(".") ); + pString->Translation() + pauseString + wxT(".") ); } // added constant needed because xMax isn't large enough for some reason, plus some space. @@ -716,16 +716,16 @@ wxString ControlToolBar::StateForStatusBar() if (!scrubState.empty()) state = scrubState.Translation(); else if (mPlay->IsDown()) - state = wxGetTranslation(sStatePlay); + state = sStatePlay.Translation(); else if (projectAudioManager.Recording()) - state = wxGetTranslation(sStateRecord); + state = sStateRecord.Translation(); else - state = wxGetTranslation(sStateStop); + state = sStateStop.Translation(); if (mPause->IsDown()) { state.Append(wxT(" ")); - state.Append(wxGetTranslation(sStatePause)); + state.Append(sStatePause.Translation()); } state.Append(wxT(".")); diff --git a/src/toolbars/EditToolBar.cpp b/src/toolbars/EditToolBar.cpp index cfe0704d9..77ca5f083 100644 --- a/src/toolbars/EditToolBar.cpp +++ b/src/toolbars/EditToolBar.cpp @@ -278,7 +278,7 @@ void EditToolBar::ForAllButtons(int Action) #if wxUSE_TOOLTIPS if( Action & ETBActTooltips ){ TranslatedInternalString command{ - entry.commandName, wxGetTranslation(entry.untranslatedLabel) }; + entry.commandName, entry.untranslatedLabel.Translation() }; ToolBar::SetButtonToolTip( mProject, *mButtons[entry.tool], &command, 1u ); } diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index b284f6ab4..d555f8d0e 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -154,7 +154,7 @@ void ToolsToolBar::RegenerateTooltips() for (const auto &entry : table) { TranslatedInternalString command{ - entry.commandName, wxGetTranslation(entry.untranslatedLabel) }; + entry.commandName, entry.untranslatedLabel.Translation() }; ToolBar::SetButtonToolTip( mProject, *mTool[entry.tool], &command, 1u ); } diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index ff4690f80..710290aa0 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -347,8 +347,8 @@ void TranscriptionToolBar::RegenerateTooltips() for (const auto &entry : table) { TranslatedInternalString commands[] = { - { entry.commandName, wxGetTranslation(entry.untranslatedLabel) }, - { entry.commandName2, wxGetTranslation(entry.untranslatedLabel2) }, + { entry.commandName, entry.untranslatedLabel.Translation() }, + { entry.commandName2, entry.untranslatedLabel2.Translation() }, }; ToolBar::SetButtonToolTip( mProject, *mButtons[entry.tool], commands, 2u ); diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index caacf7640..758c737f6 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -267,7 +267,7 @@ namespace { bool seek; bool (Scrubber::*StatusTest)() const; - const wxString &GetStatus() const { return status; } + const TranslatableString &GetStatus() const { return status; } } menuItems[] = { /* i18n-hint: These commands assist the user in finding a sound by ear. ... "Scrubbing" is variable-speed playback, ... @@ -1000,11 +1000,11 @@ registeredStatusWidthFunction{ std::vector< wxString > strings; // Note that Scrubbing + Paused is not allowed. for (const auto &item : menuItems) - strings.push_back( GetCustomTranslation( item.GetStatus() ) ); + strings.push_back( item.GetStatus().Translation() ); strings.push_back( - GetCustomTranslation( sPlayAtSpeedStatus ) + + sPlayAtSpeedStatus.Translation() + wxT(" ") + - GetCustomTranslation( XO("Paused") ) + + XO("Paused").Translation() + wxT(".") ); // added constant needed because xMax isn't large enough for some reason, plus some space. @@ -1032,7 +1032,8 @@ MenuTable::BaseItemPtr Scrubber::Menu() MenuTable::BaseItemPtrs ptrs; for (const auto &item : menuItems) { - ptrs.push_back( MenuTable::Command( item.name, wxGetTranslation(item.label), + ptrs.push_back( MenuTable::Command( + item.name, item.label.Translation(), // No menu items yet have dialogs false, findme, static_cast(item.memFn), @@ -1055,7 +1056,7 @@ void Scrubber::PopulatePopupMenu(wxMenu &menu) for (const auto &item : menuItems) { if (cm.GetEnabled(item.name)) { auto test = item.StatusTest; - menu.Append(id, wxGetTranslation(item.label), wxString{}, + menu.Append(id, item.label.Translation(), wxString{}, test ? wxITEM_CHECK : wxITEM_NORMAL); if(test && (this->*test)()) menu.FindItem(id)->Check();