1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 06:09:47 +02:00

MultiDialog uses TranslatableString for button labels & 2nd message

This commit is contained in:
Paul Licameli 2019-12-22 17:57:41 -05:00
parent 0247329077
commit 66097c34dc
4 changed files with 52 additions and 45 deletions

View File

@ -274,9 +274,13 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler)
wxString msg;
msg.Printf(_("Module \"%s\" found."), ShortName);
msg += _("\n\nOnly use modules from trusted sources");
const wxChar *buttons[] = {_("Yes"), _("No"), NULL}; // could add a button here for 'yes and remember that', and put it into the cfg file. Needs more thought.
const TranslatableStrings buttons{
XO("Yes"), XO("No"),
}; // could add a button here for 'yes and remember that', and put it into the cfg file. Needs more thought.
int action;
action = ShowMultiDialog(msg, XO("Audacity Module Loader"), buttons, _("Try and load this module?"), false);
action = ShowMultiDialog(msg, XO("Audacity Module Loader"),
buttons,
XO("Try and load this module?"), false);
#ifdef EXPERIMENTAL_MODULE_PREFS
// If we're not prompting always, accept the answer permanantly
if( iModuleStatus == kModuleNew ){

View File

@ -56,10 +56,10 @@ int ProjectFSCK(
The error message is confusing to users in English, and could just say
"Found problems with <sequence> when checking project file." */
wxString msg = _("Project check read faulty Sequence tags.");
const wxChar *buttons[] =
{_("Close project immediately with no changes"),
_("Continue with repairs noted in log, and check for more errors. This will save the project in its current state, unless you \"Close project immediately\" on further error alerts."),
NULL};
const TranslatableStrings buttons{
XO("Close project immediately with no changes"),
XO("Continue with repairs noted in log, and check for more errors. This will save the project in its current state, unless you \"Close project immediately\" on further error alerts.")
};
wxLog::FlushActive(); // MultiDialog has "Show Log..." button, so make sure log is current.
action = ShowMultiDialog(msg, XO("Warning - Problems Reading Sequence Tags"), buttons);
if (action == 0)
@ -110,11 +110,11 @@ _("Project check of \"%s\" folder \
\nproject immediately\" on further error alerts.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (long long) missingAliasFilesPathHash.size());
const wxChar *buttons[] =
{_("Close project immediately with no changes"),
_("Treat missing audio as silence (this session only)"),
_("Replace missing audio with silence (permanent immediately)."),
NULL};
const TranslatableStrings buttons{
XO("Close project immediately with no changes"),
XO("Treat missing audio as silence (this session only)"),
XO("Replace missing audio with silence (permanent immediately)."),
};
wxLog::FlushActive(); // MultiDialog has "Show Log..." button, so make sure log is current.
action = ShowMultiDialog(msg, XO("Warning - Missing Aliased File(s)"), buttons);
}
@ -188,10 +188,11 @@ _("Project check of \"%s\" folder \
\nfrom the current audio in the project.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (long long) missingAUFHash.size());
const wxChar *buttons[] = {_("Regenerate alias summary files (safe and recommended)"),
_("Fill in silence for missing display data (this session only)"),
_("Close project immediately with no further changes"),
NULL};
const TranslatableStrings buttons{
XO("Regenerate alias summary files (safe and recommended)"),
XO("Fill in silence for missing display data (this session only)"),
XO("Close project immediately with no further changes"),
};
wxLog::FlushActive(); // MultiDialog has "Show Log..." button, so make sure log is current.
action = ShowMultiDialog(msg, XO("Warning - Missing Alias Summary File(s)"), buttons);
}
@ -260,11 +261,11 @@ _("Project check of \"%s\" folder \
\nmay not show silence.");
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (long long) missingAUHash.size());
const wxChar *buttons[] =
{_("Close project immediately with no further changes"),
_("Treat missing audio as silence (this session only)"),
_("Replace missing audio with silence (permanent immediately)"),
NULL};
const TranslatableStrings buttons{
XO("Close project immediately with no further changes"),
XO("Treat missing audio as silence (this session only)"),
XO("Replace missing audio with silence (permanent immediately)"),
};
wxLog::FlushActive(); // MultiDialog has "Show Log..." button, so make sure log is current.
action = ShowMultiDialog(msg, XO("Warning - Missing Audio Data Block File(s)"), buttons);
}
@ -333,11 +334,11 @@ other projects. \
wxString msg;
msg.Printf(msgA, dm.GetProjectName(), (int)orphanFilePathArray.size());
const wxChar *buttons[] =
{_("Continue without deleting; ignore the extra files this session"),
_("Close project immediately with no further changes"),
_("Delete orphan files (permanent immediately)"),
NULL};
const TranslatableStrings buttons{
XO("Continue without deleting; ignore the extra files this session"),
XO("Close project immediately with no further changes"),
XO("Delete orphan files (permanent immediately)"),
};
wxLog::FlushActive(); // MultiDialog has "Show Log..." button, so make sure log is current.
action = ShowMultiDialog(msg, XO("Warning - Orphan Block File(s)"), buttons);
}

View File

@ -41,7 +41,8 @@ public:
MultiDialog(wxWindow * pParent,
wxString message,
const TranslatableString &title,
const wxChar **buttons, wxString boxMsg, bool log);
const TranslatableStrings &buttons,
const TranslatableString &boxMsg, bool log);
~MultiDialog() {};
private:
@ -63,7 +64,8 @@ END_EVENT_TABLE()
MultiDialog::MultiDialog(wxWindow * pParent,
wxString message,
const TranslatableString &title,
const wxChar **buttons, wxString boxMsg, bool log)
const TranslatableStrings &buttons,
const TranslatableString &boxMsg, bool log)
: wxDialogWrapper(pParent, wxID_ANY, title,
wxDefaultPosition, wxDefaultSize,
wxCAPTION) // not wxDEFAULT_DIALOG_STYLE because we don't want wxCLOSE_BOX and wxSYSTEM_MENU
@ -92,22 +94,19 @@ MultiDialog::MultiDialog(wxWindow * pParent,
vSizer->Add(iconAndTextSizer.release(), 0, wxALIGN_LEFT | wxALL, 5);
}
size_t count = 0;
while (buttons[count])count++;
ArrayOf<wxString> buttonLabels{ count };
const auto buttonLabels = transform_container<wxArrayStringEx>(
buttons, std::mem_fn( &TranslatableString::Translation ) );
count = 0;
while (buttons[count]){
buttonLabels[count] = buttons[count];
count++;
}
const auto count = buttons.size();
const auto boxStr = boxMsg.Translation();
mRadioBox = safenew wxRadioBox(this, -1,
boxMsg,
boxStr,
wxDefaultPosition, wxDefaultSize,
count, buttonLabels.get(),
count, count ? &buttonLabels[0] : nullptr,
1, wxRA_SPECIFY_COLS);
mRadioBox->SetName(boxMsg);
mRadioBox->SetName(boxStr);
mRadioBox->SetSelection(0);
vSizer->Add(mRadioBox, 1, wxEXPAND | wxALL, 5);
@ -160,7 +159,8 @@ void MultiDialog::OnShowLog(wxCommandEvent & WXUNUSED(event))
int ShowMultiDialog(const wxString &message,
const TranslatableString &title,
const wxChar **buttons, const wxString &boxMsg, bool log)
const TranslatableStrings &buttons,
const TranslatableString &boxMsg, bool log)
{
wxWindow * pParent = wxTheApp->GetTopWindow();
@ -189,7 +189,8 @@ int ShowMultiDialog(const wxString &message,
return dlog.ShowModal();
}
const wxString &DefaultMultiDialogMessage()
const TranslatableString &DefaultMultiDialogMessage()
{
return _("Please select an action");
static auto result = XO("Please select an action");
return result;
}

View File

@ -17,17 +17,18 @@
#include <wx/defs.h>
#include <wx/chartype.h> // for typedef wxChar
class TranslatableString;
#include "../Internat.h" // for TranslatableStrings
class wxString;
const wxString &DefaultMultiDialogMessage();
const TranslatableString &DefaultMultiDialogMessage();
// Display a dialog with radio buttons.
// Return the zero-based index of the chosen button.
int ShowMultiDialog(const wxString &message,
const TranslatableString &title,
const wxChar **buttons,
const wxString &boxMsg = DefaultMultiDialogMessage(),
const TranslatableStrings &buttons,
const TranslatableString &boxMsg
= DefaultMultiDialogMessage(),
bool log = true);
#endif // __AUDACITY_MULTIDIALOG__