Uses of TranslatableString as value of XO macro...

... It is not implicitly convertible from wxString, compelling many uses of
the new type to fix compilation.
This commit is contained in:
Paul Licameli 2018-03-29 16:26:31 -04:00
parent 911f5eabcc
commit e4a7c9ba5b
21 changed files with 58 additions and 61 deletions

View File

@ -28,8 +28,8 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
// Marks string for substitution only.
#define _TS( s ) GetCustomSubstitution( s )
// Marks strings for extraction only...must use wxGetTranslation() to translate.
#define XO(s) wxT(s)
// Marks strings for extraction only... use .Translate() to translate.
#define XO(s) (TranslatableString{ wxT(s) })
#ifdef _
#undef _

View File

@ -737,7 +737,7 @@ private:
static wxArrayString names()
{
static wxString theNames[] =
static TranslatableString theNames[] =
{
LABEL_ARTIST,
LABEL_TITLE,
@ -765,7 +765,7 @@ static wxArrayString names()
static const struct
{
wxString label;
TranslatableString label;
wxString name;
}
labelmap[] =

View File

@ -16,6 +16,8 @@
#include <utility>
#include <wx/string.h>
#include "audacity/Types.h"
class AudacityProject;
// Increase the template parameter as needed to allow more flags
@ -42,7 +44,7 @@ struct CommandFlagOptions{
CommandFlagOptions(
const MessageFormatter &message_,
const wxString &helpPage_ = {},
const wxString &title_ = {}
const TranslatableString &title_ = {}
) : message{ message_ }, helpPage{ helpPage_ }, title{ title_ }
{}
@ -63,7 +65,7 @@ struct CommandFlagOptions{
// Empty, or non-default title for the dialog box when the
// condition is not satisfied for the selected command
// This string must be given UN-translated.
wxString title;
TranslatableString title;
// Conditions with higher "priority" are preferred over others in choosing
// the help message

View File

@ -53,11 +53,11 @@ enum kVinyl
nVinyl
};
static const wxChar *kVinylStrings[nVinyl] =
static const TranslatableString kVinylStrings[nVinyl] =
{
wxT("33\u2153"),
wxT("45"),
wxT("78"),
XO("33\u2153"),
XO("45"),
XO("78"),
/* i18n-hint: n/a is an English abbreviation meaning "not applicable". */
XO("n/a"),
};

View File

@ -97,7 +97,7 @@ const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB);
static const struct
{
const wxChar *name;
const TranslatableString name;
EffectDistortion::Params params;
}
FactoryPresets[] =
@ -131,7 +131,7 @@ FactoryPresets[] =
wxString defaultLabel(int index)
{
static const wxString names[] = {
static const TranslatableString names[] = {
XO("Upper Threshold"),
XO("Noise Floor"),
XO("Parameter 1"),

View File

@ -1432,14 +1432,14 @@ struct ControlInfo {
vld2.SetPrecision( 0 );
vld2.SetRange( valueMin, valueMax );
wxTextCtrl *const text =
S.Id(id + 1).AddTextBox(textBoxCaption(), wxT(""), 0);
S.Id(id + 1).AddTextBox(textBoxCaption.Translation(), wxT(""), 0);
S.SetStyle(wxSL_HORIZONTAL);
text->SetValidator(vld2);
wxSlider *const slider =
S.Id(id)
.AddSlider( {}, 0, sliderMax);
slider->SetName(sliderName());
slider->SetName(sliderName.Translation());
slider->SetSizeHints(150, -1);
}
@ -1450,13 +1450,13 @@ struct ControlInfo {
// (valueMin - valueMax) / sliderMax is the value increment of the slider
const wxChar* format;
bool formatAsInt;
const wxString textBoxCaption_; wxString textBoxCaption() const { return wxGetTranslation(textBoxCaption_); }
const wxString sliderName_; wxString sliderName() const { return wxGetTranslation(sliderName_); }
const TranslatableString textBoxCaption;
const TranslatableString sliderName;
ControlInfo(MemberPointer f, double vMin, double vMax, long sMax, const wxChar* fmt, bool fAsInt,
const wxString &caption, const wxString &name)
const TranslatableString &caption, const TranslatableString &name)
: field(f), valueMin(vMin), valueMax(vMax), sliderMax(sMax), format(fmt), formatAsInt(fAsInt)
, textBoxCaption_(caption), sliderName_(name)
, textBoxCaption(caption), sliderName(name)
{
}
};

View File

@ -60,7 +60,7 @@ Param( WetOnly, bool, wxT("WetOnly"), false, false, true, 1 )
static const struct
{
const wxChar *name;
const TranslatableString name;
EffectReverb::Params params;
}
FactoryPresets[] =

View File

@ -223,7 +223,7 @@ VendorSymbol NyquistEffect::GetVendor()
return XO("Audacity");
}
return mAuthor;
return TranslatableString{ mAuthor };
}
wxString NyquistEffect::GetVersion()
@ -1890,12 +1890,12 @@ bool NyquistEffect::Parse(
}
if (len >= 2 && tokens[0] == wxT("action")) {
mAction = UnQuote(tokens[1]);
mAction = TranslatableString{ UnQuote(tokens[1]) };
return true;
}
if (len >= 2 && tokens[0] == wxT("info")) {
mInfo = UnQuote(tokens[1]);
mInfo = TranslatableString{ UnQuote(tokens[1]) };
return true;
}
@ -1945,18 +1945,18 @@ bool NyquistEffect::Parse(
#endif
if (len >= 2 && tokens[0] == wxT("author")) {
mAuthor = UnQuote(tokens[1]);
mAuthor = TranslatableString{ UnQuote(tokens[1]) };
return true;
}
if (len >= 2 && tokens[0] == wxT("release")) {
// Value must be quoted if the release version string contains spaces.
mReleaseVersion = UnQuote(tokens[1]);
mReleaseVersion = TranslatableString{ UnQuote(tokens[1]) };
return true;
}
if (len >= 2 && tokens[0] == wxT("copyright")) {
mCopyright = UnQuote(tokens[1]);
mCopyright = TranslatableString{ UnQuote(tokens[1]) };
return true;
}

View File

@ -215,14 +215,14 @@ private:
wxString mCmd; // the command to be processed
wxString mName; ///< Name of the Effect (untranslated)
wxString mPromptName; // If a prompt, we need to remember original name.
wxString mAction; // translatable
wxString mInfo; // translatable
wxString mAuthor;
TranslatableString mAction;
TranslatableString mInfo;
TranslatableString mAuthor;
// Version number of the specific plug-in (not to be confused with mVersion)
// For shipped plug-ins this will be the same as the Audacity release version
// when the plug-in was last modified.
wxString mReleaseVersion;
wxString mCopyright;
TranslatableString mReleaseVersion;
TranslatableString mCopyright;
wxString mManPage; // ONLY use if a help page exists in the manual.
wxString mHelpFile;
bool mHelpFileExists;

View File

@ -118,7 +118,7 @@ void ExportPlugin::SetFormat(const wxString & format, int index)
mFormatInfos[index].mFormat = format;
}
void ExportPlugin::SetDescription(const wxString & description, int index)
void ExportPlugin::SetDescription(const TranslatableString & description, int index)
{
mFormatInfos[index].mDescription = description;
}
@ -153,7 +153,7 @@ wxString ExportPlugin::GetFormat(int index)
return mFormatInfos[index].mFormat;
}
wxString ExportPlugin::GetUntranslatedDescription(int index)
TranslatableString ExportPlugin::GetUntranslatedDescription(int index)
{
return mFormatInfos[index].mDescription;
}

View File

@ -14,6 +14,7 @@
#include <functional>
#include <vector>
#include <wx/filename.h> // member variable
#include "audacity/Types.h"
#include "../SampleFormat.h"
#include "../widgets/wxPanelWrapper.h" // to inherit
@ -45,7 +46,7 @@ class AUDACITY_DLL_API FormatInfo
~FormatInfo() {}
wxString mFormat;
wxString mDescription; // untranslated
TranslatableString mDescription;
// wxString mExtension;
FileExtensions mExtensions;
wxString mMask;
@ -65,7 +66,7 @@ public:
int AddFormat();
void SetFormat(const wxString & format, int index);
void SetDescription(const wxString & description /* untranslated */, int index);
void SetDescription(const TranslatableString & description, int index);
void AddExtension(const wxString &extension,int index);
void SetExtensions(FileExtensions extensions, int index);
void SetMask(const wxString & mask, int index);
@ -74,7 +75,7 @@ public:
virtual int GetFormatCount();
virtual wxString GetFormat(int index);
wxString GetUntranslatedDescription(int index);
TranslatableString GetUntranslatedDescription(int index);
wxString GetTranslatedDescription(int index);
/** @brief Return the (first) file name extension for the sub-format.
* @param index The sub-format for which the extension is wanted */

View File

@ -225,7 +225,7 @@ ExportFFmpeg::ExportFFmpeg()
}
SetMaxChannels(ExportFFmpegOptions::fmts[newfmt].maxchannels,fmtindex);
SetDescription(ExportFFmpegOptions::fmts[newfmt].description_, fmtindex);
SetDescription(ExportFFmpegOptions::fmts[newfmt].description, fmtindex);
int canmeta = ExportFFmpegOptions::fmts[newfmt].canmetadata;
if (canmeta && (canmeta == AV_CANMETA || canmeta <= avfver))
@ -911,9 +911,9 @@ ProgressResult ExportFFmpeg::Export(AudacityProject *project,
InitProgress( pDialog, wxFileName(fName).GetName(),
selectionOnly
? wxString::Format(_("Exporting selected audio as %s"),
ExportFFmpegOptions::fmts[mSubFormat].Description())
ExportFFmpegOptions::fmts[mSubFormat].description.Translation())
: wxString::Format(_("Exporting the audio as %s"),
ExportFFmpegOptions::fmts[mSubFormat].Description()) );
ExportFFmpegOptions::fmts[mSubFormat].description.Translation()) );
auto &progress = *pDialog;
while (updateResult == ProgressResult::Success) {

View File

@ -1339,11 +1339,6 @@ ExposedFormat ExportFFmpegOptions::fmts[] =
{FMT_OTHER, wxT("FFMPEG"), wxT(""), wxT(""), 255, AV_CANMETA, true, XO("Custom FFmpeg Export"), AV_CODEC_ID_NONE, true}
};
wxString ExposedFormat::Description() const
{
return wxGetTranslation(description_);
}
/// Sample rates supported by AAC encoder (must end with zero-element)
const int ExportFFmpegOptions::iAACSampleRates[] = { 7350, 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 0 };

View File

@ -53,11 +53,9 @@ struct ExposedFormat
unsigned maxchannels; //!< how many channels this format could handle
const int canmetadata; //!< !=0 if format supports metadata, AV_CANMETA any avformat version, otherwise version support added
bool canutf8; //!< true if format supports metadata in UTF-8, false otherwise
const wxChar *description_; //!< format description (will be shown in export dialog) (untranslated!)
const TranslatableString description; //!< format description (will be shown in export dialog)
AVCodecID codecid; //!< codec ID (see libavcodec/avcodec.h)
bool compiledIn; //!< support for this codec/format is compiled in (checked at runtime)
wxString Description() const; // get translation
};

View File

@ -53,7 +53,7 @@ struct
{
int format;
const wxChar *name;
const wxChar *desc; // untranslated
const TranslatableString desc;
}
static const kFormats[] =
{

View File

@ -92,7 +92,7 @@ BEGIN_EVENT_TABLE(ControlToolBar, ToolBar)
EVT_IDLE(ControlToolBar::OnIdle)
END_EVENT_TABLE()
static const wxString
static const TranslatableString
sStatePlay = XO("Playing")
, sStateStop = XO("Stopped")
, sStateRecord = XO("Recording")
@ -712,9 +712,9 @@ wxString ControlToolBar::StateForStatusBar()
auto pProject = &mProject;
auto scrubState = pProject
? Scrubber::Get( *pProject ).GetUntranslatedStateString()
: wxString();
: TranslatableString{};
if (!scrubState.empty())
state = wxGetTranslation(scrubState);
state = scrubState.Translation();
else if (mPlay->IsDown())
state = wxGetTranslation(sStatePlay);
else if (projectAudioManager.Recording())

View File

@ -226,7 +226,7 @@ void EditToolBar::EnableDisableButtons()
static const struct Entry {
int tool;
CommandID commandName;
wxString untranslatedLabel;
TranslatableString untranslatedLabel;
} EditToolbarButtonList[] = {
{ ETBCutID, wxT("Cut"), XO("Cut") },
{ ETBCopyID, wxT("Copy"), XO("Copy") },

View File

@ -142,7 +142,7 @@ void ToolsToolBar::RegenerateTooltips()
static const struct Entry {
int tool;
CommandID commandName;
wxString untranslatedLabel;
TranslatableString untranslatedLabel;
} table[] = {
{ selectTool, wxT("SelectTool"), XO("Selection Tool") },
{ envelopeTool, wxT("EnvelopeTool"), XO("Envelope Tool") },

View File

@ -336,9 +336,9 @@ void TranscriptionToolBar::RegenerateTooltips()
static const struct Entry {
int tool;
CommandID commandName;
wxString untranslatedLabel;
TranslatableString untranslatedLabel;
CommandID commandName2;
wxString untranslatedLabel2;
TranslatableString untranslatedLabel2;
} table[] = {
{ TTB_PlaySpeed, wxT("PlayAtSpeed"), XO("Play-at-Speed"),
wxT("PlayAtSpeedLooped"), XO("Looped-Play-at-Speed")

View File

@ -260,8 +260,8 @@ static const ReservedCommandFlag
namespace {
const struct MenuItem {
CommandID name;
wxString label;
wxString status;
TranslatableString label;
TranslatableString status;
CommandFlag flags;
void (Scrubber::*memFn)(const CommandContext&);
bool seek;
@ -283,7 +283,7 @@ namespace {
&Scrubber::OnSeek, true, &Scrubber::Seeks,
},
{ wxT("ToggleScrubRuler"), XO("Scrub &Ruler"), wxT(""),
{ wxT("ToggleScrubRuler"), XO("Scrub &Ruler"), {},
AlwaysEnabledFlag,
&Scrubber::OnToggleScrubRuler, false, &Scrubber::ShowsBar,
},
@ -961,11 +961,11 @@ END_EVENT_TABLE()
static_assert(nMenuItems == 3, "wrong number of items");
static wxString sPlayAtSpeedStatus = XO("Playing at Speed");
static auto sPlayAtSpeedStatus = XO("Playing at Speed");
const wxString &Scrubber::GetUntranslatedStateString() const
const TranslatableString &Scrubber::GetUntranslatedStateString() const
{
static wxString empty;
static TranslatableString empty;
if (IsSpeedPlaying()) {
return sPlayAtSpeedStatus;

View File

@ -27,6 +27,7 @@ Paul Licameli split from TrackPanel.cpp
class AudacityProject;
extern AudacityProject *GetActiveProject();
class TranslatableString;
// Conditionally compile either a separate thead, or else use a timer in the main
// thread, to poll the mouse and update scrubbing speed and direction. The advantage of
@ -124,7 +125,7 @@ public:
// A string to put in the leftmost part of the status bar
// when scrub or seek is in progress, or else empty.
const wxString &GetUntranslatedStateString() const;
const TranslatableString &GetUntranslatedStateString() const;
wxString StatusMessageForWave() const;
void Pause(bool paused);