1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Pass friendly macro command names as TranslatableString

This commit is contained in:
Paul Licameli 2019-12-19 10:05:41 -05:00
parent dc39f22442
commit 2214b5ff3b
3 changed files with 19 additions and 18 deletions

View File

@ -615,7 +615,7 @@ bool MacroCommands::WriteMp3File( const wxString & Name, int bitrate )
// ======= IMPORTANT ========
// CLEANSPEECH remnant
bool MacroCommands::ApplySpecialCommand(
int WXUNUSED(iCommand), const wxString &friendlyCommand,
int WXUNUSED(iCommand), const TranslatableString &friendlyCommand,
const CommandID & command, const wxString & params)
{
if (ReportAndSkip(friendlyCommand, params))
@ -756,7 +756,7 @@ bool MacroCommands::DoAudacityCommand(
}
bool MacroCommands::ApplyEffectCommand(
const PluginID & ID, const wxString &friendlyCommand,
const PluginID & ID, const TranslatableString &friendlyCommand,
const CommandID & command, const wxString & params,
const CommandContext & Context)
{
@ -839,7 +839,7 @@ bool MacroCommands::HandleTextualCommand( CommandManager &commandManager,
return false;
}
bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
bool MacroCommands::ApplyCommand( const TranslatableString &friendlyCommand,
const CommandID & command, const wxString & params,
CommandContext const * pContext)
{
@ -872,7 +872,7 @@ bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
manager, command, *pContext, AlwaysEnabledFlag, true ) )
return true;
pContext->Status( wxString::Format(
_("Your batch command of %s was not recognized."), friendlyCommand ));
_("Your batch command of %s was not recognized."), friendlyCommand.Translation() ));
return false;
}
else
@ -890,7 +890,8 @@ bool MacroCommands::ApplyCommand( const wxString &friendlyCommand,
return false;
}
bool MacroCommands::ApplyCommandInBatchMode( const wxString &friendlyCommand,
bool MacroCommands::ApplyCommandInBatchMode(
const TranslatableString &friendlyCommand,
const CommandID & command, const wxString &params,
CommandContext const * pContext)
{
@ -946,12 +947,12 @@ bool MacroCommands::ApplyMacro(
for (; i < mCommandMacro.size(); i++) {
const auto &command = mCommandMacro[i];
auto iter = catalog.ByCommandId(command);
auto friendly = (iter == catalog.end())
const auto friendly = (iter == catalog.end())
?
// uh oh, using GET to expose an internal name to the user!
// in default of any better friendly name
command.GET()
: iter->name.StrippedTranslation();
Verbatim( command.GET() )
: iter->name.Msgid().Stripped();
if (!ApplyCommandInBatchMode(friendly, command, mParamsMacro[i]) || mAbort)
break;
}
@ -1025,7 +1026,7 @@ void MacroCommands::ResetMacro()
// ReportAndSkip() is a diagnostic function that avoids actually
// applying the requested effect if in batch-debug mode.
bool MacroCommands::ReportAndSkip(
const wxString & friendlyCommand, const wxString & params)
const TranslatableString & friendlyCommand, const wxString & params)
{
int bDebug;
gPrefs->Read(wxT("/Batch/Debug"), &bDebug, false);

View File

@ -66,20 +66,20 @@ class MacroCommands final {
static bool HandleTextualCommand( CommandManager &commandManager,
const CommandID & Str,
const CommandContext & context, CommandFlag flags, bool alwaysEnabled);
bool ApplyCommand( const wxString &friendlyCommand,
bool ApplyCommand( const TranslatableString &friendlyCommand,
const CommandID & command, const wxString & params,
CommandContext const * pContext=NULL );
bool ApplyCommandInBatchMode( const wxString &friendlyCommand,
bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand,
const CommandID & command, const wxString &params,
CommandContext const * pContext = NULL);
bool ApplySpecialCommand(
int iCommand, const wxString &friendlyCommand,
int iCommand, const TranslatableString &friendlyCommand,
const CommandID & command, const wxString & params);
bool ApplyEffectCommand(
const PluginID & ID, const wxString &friendlyCommand,
const PluginID & ID, const TranslatableString &friendlyCommand,
const CommandID & command,
const wxString & params, const CommandContext & Context);
bool ReportAndSkip( const wxString & friendlyCommand, const wxString & params );
bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params );
void AbortBatch();
// Utility functions for the special commands.

View File

@ -59,12 +59,12 @@ bool BatchEvalCommand::Apply(const CommandContext & context)
return batch.ApplyMacro(catalog);
}
wxString cmdName = GetString(wxT("CommandName"));
auto cmdName = GetString(wxT("CommandName"));
wxString cmdParams = GetString(wxT("ParamString"));
auto iter = catalog.ByCommandId(cmdName);
const wxString &friendly = (iter == catalog.end())
? cmdName // Expose internal name to user, in default of a better one!
: iter->name.StrippedTranslation();
const auto friendly = (iter == catalog.end())
? Verbatim( cmdName ) // Expose internal name to user, in default of a better one!
: iter->name.Msgid().Stripped();
// Create a Batch that will have just one command in it...
MacroCommands Batch;