From 3b90538b84411f6b08e10682406984e5f499fd74 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 5 Oct 2017 14:13:01 -0400 Subject: [PATCH 1/4] Remove description from PluginDescriptor... ... it was simply written to registry and read again, serving no other purpose. But still write a blank to registry for backwards compatibility of the .cfg file. This makes it irrelevant whether the value of IdentInterface::GetDescription() ought to be localized (registry values should probably not be). Therefore IdentInterface::GetDescription can return localized, and it's all right that the return be computed (as in VST effects), rather than an unlocalized msgid that we rely on as an internal identifier. --- src/PluginManager.cpp | 22 +++++++++------------- src/PluginManager.h | 3 --- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 838373e50..e32fa5cbe 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1160,11 +1160,6 @@ wxString PluginDescriptor::GetVendor(bool translate) const return translate ? wxString(wxGetTranslation(mVendor)) : mVendor; } -wxString PluginDescriptor::GetDescription(bool translate) const -{ - return translate ? wxString(wxGetTranslation(mDescription)) : mDescription; -} - bool PluginDescriptor::IsEnabled() const { return mEnabled; @@ -1215,11 +1210,6 @@ void PluginDescriptor::SetVendor(const wxString & vendor) mVendor = vendor; } -void PluginDescriptor::SetDescription(const wxString & description) -{ - mDescription = description; -} - void PluginDescriptor::SetEnabled(bool enable) { mEnabled = enable; @@ -2015,12 +2005,18 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) } plug.SetVendor(strVal); +#if 0 + // This was done before version 2.2.2, but the value was not really used + // But absence of a value will cause early versions to skip the group + // Therefore we still write a blank to keep pluginregistry.cfg + // backwards-compatible + // Get the description and bypass group if not found if (!pRegistry->Read(KEY_DESCRIPTION, &strVal)) { continue; } - plug.SetDescription(strVal); +#endif // Is it enabled...default to no if not found pRegistry->Read(KEY_ENABLED, &boolVal, false); @@ -2212,7 +2208,8 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) pRegistry->Write(KEY_NAME, plug.GetName(false)); pRegistry->Write(KEY_VERSION, plug.GetVersion(false)); pRegistry->Write(KEY_VENDOR, plug.GetVendor(false)); - pRegistry->Write(KEY_DESCRIPTION, plug.GetDescription(false)); + // Write a blank -- see comments in LoadGroup: + pRegistry->Write(KEY_DESCRIPTION, wxString{}); pRegistry->Write(KEY_PROVIDERID, plug.GetProviderID()); pRegistry->Write(KEY_ENABLED, plug.IsEnabled()); pRegistry->Write(KEY_VALID, plug.IsValid()); @@ -2660,7 +2657,6 @@ PluginDescriptor & PluginManager::CreatePlugin(const PluginID & id, plug.SetName(ident->GetName()); plug.SetVendor(ident->GetVendor()); plug.SetVersion(ident->GetVersion()); - plug.SetDescription(ident->GetDescription()); return plug; } diff --git a/src/PluginManager.h b/src/PluginManager.h index a1c2dd4a3..0c335256c 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -66,7 +66,6 @@ public: wxString GetName(bool translate = true) const; wxString GetVersion(bool translate = true) const; wxString GetVendor(bool translate = true) const; - wxString GetDescription(bool translate = true) const; bool IsEnabled() const; bool IsValid() const; @@ -81,7 +80,6 @@ public: void SetName(const wxString & name); void SetVersion(const wxString & version); void SetVendor(const wxString & vendor); - void SetDescription(const wxString & description); void SetEnabled(bool enable); void SetValid(bool valid); @@ -135,7 +133,6 @@ private: wxString mName; wxString mVersion; wxString mVendor; - wxString mDescription; wxString mProviderID; bool mEnabled; bool mValid; From 91b0e82c11bc0e12d1581e3b583a660188b9e920 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 5 Jan 2018 17:32:20 -0500 Subject: [PATCH 2/4] PluginDescriptor versions are in fact untranslated; make that clear... ... though the version (like the description) really wasn't yet used for anything but to write and read again from the registry, still keep writing it. Because it is appropriate to write untranslated strings to the registry, and perhaps the values in old registries really will find a future use. --- src/PluginManager.cpp | 6 +++--- src/PluginManager.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index e32fa5cbe..7f93b4642 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1150,9 +1150,9 @@ wxString PluginDescriptor::GetName(bool translate) const return translate ? wxString(wxGetTranslation(mName)) : mName; } -wxString PluginDescriptor::GetVersion(bool translate) const +wxString PluginDescriptor::GetUntranslatedVersion() const { - return translate ? wxString(wxGetTranslation(mVersion)) : mVersion; + return mVersion; } wxString PluginDescriptor::GetVendor(bool translate) const @@ -2206,7 +2206,7 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) pRegistry->Write(KEY_PATH, plug.GetPath()); pRegistry->Write(KEY_SYMBOL, plug.GetSymbol()); pRegistry->Write(KEY_NAME, plug.GetName(false)); - pRegistry->Write(KEY_VERSION, plug.GetVersion(false)); + pRegistry->Write(KEY_VERSION, plug.GetUntranslatedVersion()); pRegistry->Write(KEY_VENDOR, plug.GetVendor(false)); // Write a blank -- see comments in LoadGroup: pRegistry->Write(KEY_DESCRIPTION, wxString{}); diff --git a/src/PluginManager.h b/src/PluginManager.h index 0c335256c..f223b6bf7 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -62,9 +62,10 @@ public: const wxString & GetPath() const; const wxString & GetSymbol() const; + wxString GetUntranslatedVersion() const; + // These return translated strings (if available and if requested) wxString GetName(bool translate = true) const; - wxString GetVersion(bool translate = true) const; wxString GetVendor(bool translate = true) const; bool IsEnabled() const; bool IsValid() const; From cafbff9ff82520ff7d4344570385752869c6d230 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 3 Oct 2017 09:02:22 -0400 Subject: [PATCH 3/4] Separate plugin accessors for translated and unstranslated strings... ... because I want to make a type distinction later. Replace calls to GetXXX() without argument, with GetTranslatedXXX() -- this reveals a subtle error, see next commit. --- src/Menus.cpp | 48 ++++++++++++++++++++-------------------- src/PluginManager.cpp | 51 ++++++++++++++++++++++++++++--------------- src/PluginManager.h | 13 ++++++----- 3 files changed, 65 insertions(+), 47 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 5383710e9..f78aeff4b 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -171,8 +171,8 @@ enum { WX_DEFINE_ARRAY_PTR(const PluginDescriptor *, EffectPlugs); static int SortEffectsByName(const PluginDescriptor **a, const PluginDescriptor **b) { - wxString akey = (*a)->GetName(); - wxString bkey = (*b)->GetName(); + wxString akey = (*a)->GetTranslatedName(); + wxString bkey = (*b)->GetTranslatedName(); akey += (*a)->GetPath(); bkey += (*b)->GetPath(); @@ -182,8 +182,8 @@ static int SortEffectsByName(const PluginDescriptor **a, const PluginDescriptor static int SortEffectsByPublisher(const PluginDescriptor **a, const PluginDescriptor **b) { - wxString akey = (*a)->GetVendor(); - wxString bkey = (*b)->GetVendor(); + wxString akey = (*a)->GetTranslatedVendor(); + wxString bkey = (*b)->GetTranslatedVendor(); if (akey.IsEmpty()) { @@ -194,8 +194,8 @@ static int SortEffectsByPublisher(const PluginDescriptor **a, const PluginDescri bkey = _("Uncategorized"); } - akey += (*a)->GetName(); - bkey += (*b)->GetName(); + akey += (*a)->GetTranslatedName(); + bkey += (*b)->GetTranslatedName(); akey += (*a)->GetPath(); bkey += (*b)->GetPath(); @@ -205,8 +205,8 @@ static int SortEffectsByPublisher(const PluginDescriptor **a, const PluginDescri static int SortEffectsByPublisherAndName(const PluginDescriptor **a, const PluginDescriptor **b) { - wxString akey = (*a)->GetVendor(); - wxString bkey = (*b)->GetVendor(); + wxString akey = (*a)->GetTranslatedVendor(); + wxString bkey = (*b)->GetTranslatedVendor(); if ((*a)->IsEffectDefault()) { @@ -217,8 +217,8 @@ static int SortEffectsByPublisherAndName(const PluginDescriptor **a, const Plugi bkey = wxEmptyString; } - akey += (*a)->GetName(); - bkey += (*b)->GetName(); + akey += (*a)->GetTranslatedName(); + bkey += (*b)->GetTranslatedName(); akey += (*a)->GetPath(); bkey += (*b)->GetPath(); @@ -228,8 +228,8 @@ static int SortEffectsByPublisherAndName(const PluginDescriptor **a, const Plugi static int SortEffectsByTypeAndName(const PluginDescriptor **a, const PluginDescriptor **b) { - wxString akey = (*a)->GetEffectFamily(); - wxString bkey = (*b)->GetEffectFamily(); + wxString akey = (*a)->GetTranslatedEffectFamily(); + wxString bkey = (*b)->GetTranslatedEffectFamily(); if (akey.IsEmpty()) { @@ -249,8 +249,8 @@ static int SortEffectsByTypeAndName(const PluginDescriptor **a, const PluginDesc bkey = wxEmptyString; } - akey += (*a)->GetName(); - bkey += (*b)->GetName(); + akey += (*a)->GetTranslatedName(); + bkey += (*b)->GetTranslatedName(); akey += (*a)->GetPath(); bkey += (*b)->GetPath(); @@ -260,8 +260,8 @@ static int SortEffectsByTypeAndName(const PluginDescriptor **a, const PluginDesc static int SortEffectsByType(const PluginDescriptor **a, const PluginDescriptor **b) { - wxString akey = (*a)->GetEffectFamily(); - wxString bkey = (*b)->GetEffectFamily(); + wxString akey = (*a)->GetTranslatedEffectFamily(); + wxString bkey = (*b)->GetTranslatedEffectFamily(); if (akey.IsEmpty()) { @@ -272,8 +272,8 @@ static int SortEffectsByType(const PluginDescriptor **a, const PluginDescriptor bkey = _("Uncategorized"); } - akey += (*a)->GetName(); - bkey += (*b)->GetName(); + akey += (*a)->GetTranslatedName(); + bkey += (*b)->GetTranslatedName(); akey += (*a)->GetPath(); bkey += (*b)->GetPath(); @@ -1711,7 +1711,7 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, { const PluginDescriptor *plug = plugs[i]; - wxString name = plug->GetName(); + wxString name = plug->GetTranslatedName(); if (plug->IsEffectInteractive()) { @@ -1720,7 +1720,7 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, if (groupBy == wxT("groupby:publisher")) { - current = plug->GetVendor(); + current = plug->GetTranslatedVendor(); if (current.IsEmpty()) { current = _("Unknown"); @@ -1728,7 +1728,7 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, } else if (groupBy == wxT("groupby:type")) { - current = plug->GetEffectFamily(); + current = plug->GetTranslatedEffectFamily(); if (current.IsEmpty()) { current = _("Unknown"); @@ -1775,7 +1775,7 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, { const PluginDescriptor *plug = plugs[i]; - wxString name = plug->GetName(); + wxString name = plug->GetTranslatedName(); if (plug->IsEffectInteractive()) { @@ -1785,11 +1785,11 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, wxString group = wxEmptyString; if (groupBy == wxT("sortby:publisher:name")) { - group = plug->GetVendor(); + group = plug->GetTranslatedVendor(); } else if (groupBy == wxT("sortby:type:name")) { - group = plug->GetEffectFamily(); + group = plug->GetTranslatedEffectFamily(); } if (plug->IsEffectDefault()) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 7f93b4642..ccb5435e5 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -628,7 +628,7 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) if (plugType == PluginTypeEffect) { - item.name = plug.GetName(); + item.name = plug.GetTranslatedName(); } // This is not right and will not work when other plugin types are added. // But it's presumed that the plugin manager dialog will be fully developed @@ -1145,9 +1145,9 @@ const wxString & PluginDescriptor::GetSymbol() const return mSymbol; } -wxString PluginDescriptor::GetName(bool translate) const +wxString PluginDescriptor::GetUntranslatedName() const { - return translate ? wxString(wxGetTranslation(mName)) : mName; + return mName; } wxString PluginDescriptor::GetUntranslatedVersion() const @@ -1155,9 +1155,19 @@ wxString PluginDescriptor::GetUntranslatedVersion() const return mVersion; } -wxString PluginDescriptor::GetVendor(bool translate) const +wxString PluginDescriptor::GetTranslatedName() const { - return translate ? wxString(wxGetTranslation(mVendor)) : mVendor; + return wxGetTranslation(mName); +} + +wxString PluginDescriptor::GetUntranslatedVendor() const +{ + return mVendor; +} + +wxString PluginDescriptor::GetTranslatedVendor() const +{ + return wxGetTranslation(mVendor); } bool PluginDescriptor::IsEnabled() const @@ -1222,9 +1232,14 @@ void PluginDescriptor::SetValid(bool valid) // Effects -wxString PluginDescriptor::GetEffectFamily(bool translate) const +wxString PluginDescriptor::GetUntranslatedEffectFamily() const { - return translate ? wxString(wxGetTranslation(mEffectFamily)) : mEffectFamily; + return mEffectFamily; +} + +wxString PluginDescriptor::GetTranslatedEffectFamily() const +{ + return wxGetTranslation(mEffectFamily); } EffectType PluginDescriptor::GetEffectType() const @@ -1987,7 +2002,7 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) // Get the symbol...use name if not found if (!pRegistry->Read(KEY_SYMBOL, &strVal)) { - strVal = plug.GetName(); + strVal = plug.GetTranslatedName(); } plug.SetSymbol(strVal); @@ -2205,9 +2220,9 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) pRegistry->Write(KEY_PATH, plug.GetPath()); pRegistry->Write(KEY_SYMBOL, plug.GetSymbol()); - pRegistry->Write(KEY_NAME, plug.GetName(false)); + pRegistry->Write(KEY_NAME, plug.GetUntranslatedName()); pRegistry->Write(KEY_VERSION, plug.GetUntranslatedVersion()); - pRegistry->Write(KEY_VENDOR, plug.GetVendor(false)); + pRegistry->Write(KEY_VENDOR, plug.GetUntranslatedVendor()); // Write a blank -- see comments in LoadGroup: pRegistry->Write(KEY_DESCRIPTION, wxString{}); pRegistry->Write(KEY_PROVIDERID, plug.GetProviderID()); @@ -2244,7 +2259,7 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) stype = KEY_EFFECTTYPE_HIDDEN; } pRegistry->Write(KEY_EFFECTTYPE, stype); - pRegistry->Write(KEY_EFFECTFAMILY, plug.GetEffectFamily(false)); + pRegistry->Write(KEY_EFFECTFAMILY, plug.GetUntranslatedEffectFamily()); pRegistry->Write(KEY_EFFECTDEFAULT, plug.IsEffectDefault()); pRegistry->Write(KEY_EFFECTINTERACTIVE, plug.IsEffectInteractive()); pRegistry->Write(KEY_EFFECTREALTIME, plug.IsEffectRealtime()); @@ -2442,7 +2457,7 @@ const PluginDescriptor *PluginManager::GetFirstPlugin(PluginType type) bool familyEnabled = true; if (type == PluginTypeEffect) { - gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true); + gPrefs->Read(plug.GetTranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); } if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled) { @@ -2461,7 +2476,7 @@ const PluginDescriptor *PluginManager::GetNextPlugin(PluginType type) bool familyEnabled = true; if (type == PluginTypeEffect) { - gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true); + gPrefs->Read(plug.GetTranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); } if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled) { @@ -2481,7 +2496,7 @@ const PluginDescriptor *PluginManager::GetFirstPluginForEffectType(EffectType ty PluginDescriptor & plug = mPluginsIter->second; bool familyEnabled; - gPrefs->Read(plug.GetEffectFamily(false) + wxT("/Enable"), &familyEnabled, true); + gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled) { if (plug.IsInstantiated() && em.IsHidden(plug.GetID())) @@ -2504,7 +2519,7 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ { PluginDescriptor & plug = mPluginsIter->second; bool familyEnabled; - gPrefs->Read(plug.GetEffectFamily() + wxT("/Enable"), &familyEnabled, true); + gPrefs->Read(plug.GetTranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled) { if (plug.IsInstantiated() && em.IsHidden(plug.GetID())) @@ -2557,7 +2572,7 @@ wxString PluginManager::GetName(const PluginID & ID) return wxEmptyString; } - return mPlugins[ID].GetName(); + return mPlugins[ID].GetTranslatedName(); } IdentInterface *PluginManager::GetInstance(const PluginID & ID) @@ -2893,9 +2908,9 @@ wxString PluginManager::SettingsPath(const PluginID & ID, bool shared) wxString id = GetPluginTypeString(plug.GetPluginType()) + wxT("_") + - plug.GetEffectFamily(false) + // is empty for non-Effects + plug.GetUntranslatedEffectFamily() + // is empty for non-Effects wxT("_") + - plug.GetVendor(false) + + plug.GetUntranslatedVendor() + wxT("_") + (shared ? wxT("") : plug.GetSymbol()); diff --git a/src/PluginManager.h b/src/PluginManager.h index f223b6bf7..1f6e4dc04 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -63,10 +63,13 @@ public: const wxString & GetSymbol() const; wxString GetUntranslatedVersion() const; + // There is no translated version - // These return translated strings (if available and if requested) - wxString GetName(bool translate = true) const; - wxString GetVendor(bool translate = true) const; + wxString GetUntranslatedName() const; + wxString GetTranslatedName() const; + + wxString GetUntranslatedVendor() const; + wxString GetTranslatedVendor() const; bool IsEnabled() const; bool IsValid() const; @@ -87,8 +90,8 @@ public: // Effect plugins only - // Will return an untranslated string - wxString GetEffectFamily(bool translate = true) const; + wxString GetUntranslatedEffectFamily() const; + wxString GetTranslatedEffectFamily() const; EffectType GetEffectType() const; bool IsEffectDefault() const; bool IsEffectInteractive() const; From c6bbe4c3dae8a52bb4b7a3c720af97bc3bd69769 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 5 Jan 2018 18:17:21 -0500 Subject: [PATCH 4/4] Fix subtle error revealed by the previous commit ... ... A "translated" effect family string, plus "/Enable", was used as a registry key for lookup! It is wrong to key on a translation. But in fact exhaustive search for "/Enable" shows that the only such strings for which a written (by EffectsPrefs) registry value could be found were AudioUnit Ladspa LV2 Nyquist VAMP VST And none of these was actually a msgid in audacity.pot. So nothing bad can really have happened in other locale settings. --- src/PluginManager.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index ccb5435e5..da819528e 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -2457,7 +2457,8 @@ const PluginDescriptor *PluginManager::GetFirstPlugin(PluginType type) bool familyEnabled = true; if (type == PluginTypeEffect) { - gPrefs->Read(plug.GetTranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); + // This preference may be written by EffectsPrefs + gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); } if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled) { @@ -2476,7 +2477,8 @@ const PluginDescriptor *PluginManager::GetNextPlugin(PluginType type) bool familyEnabled = true; if (type == PluginTypeEffect) { - gPrefs->Read(plug.GetTranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); + // This preference may be written by EffectsPrefs + gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); } if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled) { @@ -2496,6 +2498,7 @@ const PluginDescriptor *PluginManager::GetFirstPluginForEffectType(EffectType ty PluginDescriptor & plug = mPluginsIter->second; bool familyEnabled; + // This preference may be written by EffectsPrefs gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled) { @@ -2519,7 +2522,8 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ { PluginDescriptor & plug = mPluginsIter->second; bool familyEnabled; - gPrefs->Read(plug.GetTranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); + // This preference may be written by EffectsPrefs + gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled) { if (plug.IsInstantiated() && em.IsHidden(plug.GetID()))