1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 07:59:27 +02:00

Fix mix of internal and translated strings naming Align commands...

... Revert commit 357b05efd29366b3b5b18202ea317d4e90ee9b80, and use
Ukrainian, and open Select Commands in Macros, to see the problem
This commit is contained in:
Paul Licameli 2018-03-15 19:39:25 -04:00
parent 9b7ccc4dff
commit 9780c14882
3 changed files with 34 additions and 28 deletions

View File

@ -1020,17 +1020,19 @@ void AudacityProject::CreateMenusAndCommands()
//////////////////////////////////////////////////////////////////////////
wxArrayString alignLabelsNoSync;
alignLabelsNoSync.Add(_("&Align End to End"));
alignLabelsNoSync.Add(_("Align &Together"));
const TranslatedInternalString alignLabelsNoSync[] = {
{ wxT("EndToEnd"), _("&Align End to End") },
{ wxT("Together"), _("Align &Together") },
};
wxArrayString alignLabels;
alignLabels.Add(_("Start to &Zero"));
alignLabels.Add(_("Start to &Cursor/Selection Start"));
alignLabels.Add(_("Start to Selection &End"));
alignLabels.Add(_("End to Cu&rsor/Selection Start"));
alignLabels.Add(_("End to Selection En&d"));
mAlignLabelsCount = alignLabels.GetCount();
const TranslatedInternalString alignLabels[] = {
{ wxT("StartToZero"), _("Start to &Zero") },
{ wxT("StartToSelStart"), _("Start to &Cursor/Selection Start") },
{ wxT("StartToSelEnd"), _("Start to Selection &End") },
{ wxT("EndToSelStart"), _("End to Cu&rsor/Selection Start") },
{ wxT("EndToSelEnd"), _("End to Selection En&d") },
};
mAlignLabelsCount = sizeof(alignLabels) / sizeof(alignLabels[0]);
// Calling c->SetCommandFlags() after AddItemList for "Align" and "AlignMove"
// does not correctly set flags for submenus, so do it this way.
@ -1040,9 +1042,9 @@ void AudacityProject::CreateMenusAndCommands()
c->BeginSubMenu(_("&Align Tracks"));
//c->BeginSubMenu(_("Just Move Tracks"));
c->AddItemList(wxT("Align"), alignLabelsNoSync, FN(OnAlignNoSync));
c->AddItemList(wxT("Align"), alignLabelsNoSync, 2u, FN(OnAlignNoSync));
c->AddSeparator();
c->AddItemList(wxT("Align"), alignLabels, FN(OnAlign));
c->AddItemList(wxT("Align"), alignLabels, mAlignLabelsCount, FN(OnAlign));
c->AddSeparator();
c->AddCheck(wxT("MoveSelectionWithTracks"), _("&Move Selection with Tracks (on/off)"),
FN(OnMoveSelectionWithTracks),
@ -1054,7 +1056,7 @@ void AudacityProject::CreateMenusAndCommands()
// TODO: Can these labels be made clearer? Do we need this sub-menu at all?
c->BeginSubMenu(_("Move Sele&ction and Tracks"));
c->AddItemList(wxT("AlignMove"), alignLabels, FN(OnAlignMoveSel));
c->AddItemList(wxT("AlignMove"), alignLabels, mAlignLabelsCount, FN(OnAlignMoveSel));
c->SetCommandFlags(wxT("AlignMove"),
AudioIONotBusyFlag | TracksSelectedFlag,
AudioIONotBusyFlag | TracksSelectedFlag);

View File

@ -760,7 +760,7 @@ void CommandManager::InsertItem(const wxString & name,
}
}
CommandListEntry *entry = NewIdentifier(name, label_in, menu, finder, callback, false, 0, 0, false);
CommandListEntry *entry = NewIdentifier(name, label_in, menu, finder, callback, {}, 0, 0, false);
int ID = entry->id;
wxString label = GetLabel(entry);
@ -828,7 +828,7 @@ void CommandManager::AddItem(const wxChar *name,
cookedParameter = parameter;
CommandListEntry *entry =
NewIdentifier(name, label_in, accel, CurrentMenu(), finder, callback,
false, 0, 0, bIsEffect, cookedParameter);
{}, 0, 0, bIsEffect, cookedParameter);
int ID = entry->id;
wxString label = GetLabelWithDisabledAccel(entry);
@ -855,18 +855,19 @@ void CommandManager::AddItem(const wxChar *name,
/// When you call Enable on this command name, it will enable or disable
/// all of the items at once.
void CommandManager::AddItemList(const wxString & name,
const wxArrayString & labels,
const TranslatedInternalString items[],
size_t nItems,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool bIsEffect)
{
for (size_t i = 0, cnt = labels.GetCount(); i < cnt; i++) {
for (size_t i = 0, cnt = nItems; i < cnt; i++) {
CommandListEntry *entry = NewIdentifier(name,
labels[i],
items[i].Translated(),
CurrentMenu(),
finder,
callback,
true,
items[i].Internal(),
i,
cnt,
bIsEffect);
@ -896,7 +897,7 @@ void CommandManager::AddCommand(const wxChar *name,
CommandFlag flags,
CommandMask mask)
{
NewIdentifier(name, label_in, accel, NULL, finder, callback, false, 0, 0, false, {});
NewIdentifier(name, label_in, accel, NULL, finder, callback, {}, 0, 0, false, {});
if (flags != NoFlagsSpecifed || mask != NoFlagsSpecifed) {
SetCommandFlags(name, flags, mask);
@ -911,7 +912,7 @@ void CommandManager::AddGlobalCommand(const wxChar *name,
{
CommandListEntry *entry =
NewIdentifier(name, label_in, accel, NULL, finder, callback,
false, 0, 0, false, {});
{}, 0, 0, false, {});
entry->enabled = false;
entry->isGlobal = true;
@ -947,7 +948,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
wxMenu *menu,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
const wxString &nameSuffix,
int index,
int count,
bool bIsEffect)
@ -958,7 +959,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
menu,
finder,
callback,
multi,
nameSuffix,
index,
count,
bIsEffect,
@ -971,12 +972,13 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & nameIn,
wxMenu *menu,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
const wxString &nameSuffix,
int index,
int count,
bool bIsEffect,
const CommandParameter &parameter)
{
const bool multi = !nameSuffix.empty();
wxString name = nameIn;
// If we have the identifier already, reuse it.
@ -1001,7 +1003,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & nameIn,
// This feature is not used for built-in effects.
if (multi) {
// The name needs to be clean for use by automation.
wxString cleanedName = wxString::Format(wxT("%s_%s"), name, label);
wxString cleanedName = wxString::Format(wxT("%s_%s"), name, nameSuffix);
cleanedName.Replace( "/", "" );
cleanedName.Replace( "&", "" );
cleanedName.Replace( " ", "" );

View File

@ -33,6 +33,7 @@
#endif
using CommandParameter = wxString;
class TranslatedInternalString;
struct MenuBarListEntry
{
@ -161,7 +162,8 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
int checkmark = -1);
void AddItemList(const wxString & name,
const wxArrayString & labels,
const TranslatedInternalString items[],
size_t nItems,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool bIsEffect = false);
@ -334,7 +336,7 @@ protected:
wxMenu *menu,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
const wxString &nameSuffix,
int index,
int count,
bool bIsEffect);
@ -344,7 +346,7 @@ protected:
wxMenu *menu,
CommandHandlerFinder finder,
CommandFunctorPointer callback,
bool multi,
const wxString &nameSuffix,
int index,
int count,
bool bIsEffect,