mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-25 08:38:39 +02:00
Reviewed whether fields of PluginDescriptor are translated or not...
... Threw away one field as unused; found a subtle but inconsequential mistake in the use of another. Fields that are stored for the purpose of internal identifiers should be untranslated. Strings used to form registry keys should certainly be untranslated. Translations should only happen for purposes of display to the user.
This commit is contained in:
commit
0badd25844
@ -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())
|
||||
|
@ -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,24 +1145,29 @@ 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::GetVersion(bool translate) const
|
||||
wxString PluginDescriptor::GetUntranslatedVersion() const
|
||||
{
|
||||
return translate ? wxString(wxGetTranslation(mVersion)) : mVersion;
|
||||
return mVersion;
|
||||
}
|
||||
|
||||
wxString PluginDescriptor::GetVendor(bool translate) const
|
||||
wxString PluginDescriptor::GetTranslatedName() const
|
||||
{
|
||||
return translate ? wxString(wxGetTranslation(mVendor)) : mVendor;
|
||||
return wxGetTranslation(mName);
|
||||
}
|
||||
|
||||
wxString PluginDescriptor::GetDescription(bool translate) const
|
||||
wxString PluginDescriptor::GetUntranslatedVendor() const
|
||||
{
|
||||
return translate ? wxString(wxGetTranslation(mDescription)) : mDescription;
|
||||
return mVendor;
|
||||
}
|
||||
|
||||
wxString PluginDescriptor::GetTranslatedVendor() const
|
||||
{
|
||||
return wxGetTranslation(mVendor);
|
||||
}
|
||||
|
||||
bool PluginDescriptor::IsEnabled() const
|
||||
@ -1215,11 +1220,6 @@ void PluginDescriptor::SetVendor(const wxString & vendor)
|
||||
mVendor = vendor;
|
||||
}
|
||||
|
||||
void PluginDescriptor::SetDescription(const wxString & description)
|
||||
{
|
||||
mDescription = description;
|
||||
}
|
||||
|
||||
void PluginDescriptor::SetEnabled(bool enable)
|
||||
{
|
||||
mEnabled = enable;
|
||||
@ -1232,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
|
||||
@ -1997,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);
|
||||
|
||||
@ -2015,12 +2020,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);
|
||||
@ -2209,10 +2220,11 @@ 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_VENDOR, plug.GetVendor(false));
|
||||
pRegistry->Write(KEY_DESCRIPTION, plug.GetDescription(false));
|
||||
pRegistry->Write(KEY_NAME, plug.GetUntranslatedName());
|
||||
pRegistry->Write(KEY_VERSION, plug.GetUntranslatedVersion());
|
||||
pRegistry->Write(KEY_VENDOR, plug.GetUntranslatedVendor());
|
||||
// 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());
|
||||
@ -2247,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());
|
||||
@ -2445,7 +2457,8 @@ const PluginDescriptor *PluginManager::GetFirstPlugin(PluginType type)
|
||||
bool familyEnabled = true;
|
||||
if (type == PluginTypeEffect)
|
||||
{
|
||||
gPrefs->Read(plug.GetEffectFamily() + 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)
|
||||
{
|
||||
@ -2464,7 +2477,8 @@ const PluginDescriptor *PluginManager::GetNextPlugin(PluginType type)
|
||||
bool familyEnabled = true;
|
||||
if (type == PluginTypeEffect)
|
||||
{
|
||||
gPrefs->Read(plug.GetEffectFamily() + 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)
|
||||
{
|
||||
@ -2484,7 +2498,8 @@ const PluginDescriptor *PluginManager::GetFirstPluginForEffectType(EffectType ty
|
||||
PluginDescriptor & plug = mPluginsIter->second;
|
||||
|
||||
bool familyEnabled;
|
||||
gPrefs->Read(plug.GetEffectFamily(false) + 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()))
|
||||
@ -2507,7 +2522,8 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ
|
||||
{
|
||||
PluginDescriptor & plug = mPluginsIter->second;
|
||||
bool familyEnabled;
|
||||
gPrefs->Read(plug.GetEffectFamily() + 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()))
|
||||
@ -2560,7 +2576,7 @@ wxString PluginManager::GetName(const PluginID & ID)
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
return mPlugins[ID].GetName();
|
||||
return mPlugins[ID].GetTranslatedName();
|
||||
}
|
||||
|
||||
IdentInterface *PluginManager::GetInstance(const PluginID & ID)
|
||||
@ -2660,7 +2676,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;
|
||||
}
|
||||
@ -2897,9 +2912,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());
|
||||
|
||||
|
@ -62,11 +62,14 @@ public:
|
||||
const wxString & GetPath() const;
|
||||
const wxString & GetSymbol() 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;
|
||||
wxString GetDescription(bool translate = true) const;
|
||||
wxString GetUntranslatedVersion() const;
|
||||
// There is no translated version
|
||||
|
||||
wxString GetUntranslatedName() const;
|
||||
wxString GetTranslatedName() const;
|
||||
|
||||
wxString GetUntranslatedVendor() const;
|
||||
wxString GetTranslatedVendor() const;
|
||||
bool IsEnabled() const;
|
||||
bool IsValid() const;
|
||||
|
||||
@ -81,15 +84,14 @@ 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);
|
||||
|
||||
// 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;
|
||||
@ -135,7 +137,6 @@ private:
|
||||
wxString mName;
|
||||
wxString mVersion;
|
||||
wxString mVendor;
|
||||
wxString mDescription;
|
||||
wxString mProviderID;
|
||||
bool mEnabled;
|
||||
bool mValid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user