1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 16:39:30 +02:00

TranslatableString for names, labels, tooltips of wxPanelWrapper...

... and Grabber too
This commit is contained in:
Paul Licameli 2019-12-07 21:00:39 -05:00
parent 53ee9c9800
commit 681950fc61
56 changed files with 204 additions and 140 deletions

View File

@ -540,6 +540,9 @@ inline TranslatableString operator +(
using TranslatableStrings = std::vector<TranslatableString>; using TranslatableStrings = std::vector<TranslatableString>;
// A special string value that will have no screen reader pronunciation
extern const TranslatableString InaudibleString;
// For using std::unordered_map on TranslatableString // For using std::unordered_map on TranslatableString
// Note: hashing on msgids only, which is not all of the information // Note: hashing on msgids only, which is not all of the information
namespace std namespace std

View File

@ -415,9 +415,9 @@ public:
(void)state;// Compiler food (void)state;// Compiler food
// May come here when recording is in progress, so hit tests are turned // May come here when recording is in progress, so hit tests are turned
// off. // off.
wxString tooltip; TranslatableString tooltip;
if (mParent->mTimelineToolTip) if (mParent->mTimelineToolTip)
tooltip = _("Timeline actions disabled during recording"); tooltip = XO("Timeline actions disabled during recording");
static wxCursor cursor{ wxCURSOR_DEFAULT }; static wxCursor cursor{ wxCURSOR_DEFAULT };
return { return {
@ -628,7 +628,7 @@ protected:
return { return {
_( "Click and drag to adjust, double-click to reset" ), _( "Click and drag to adjust, double-click to reset" ),
&cursor, &cursor,
_( "Record/Play head" ) XO( "Record/Play head" )
}; };
} }
@ -903,8 +903,8 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* project,
for (auto &button : mButtons) for (auto &button : mButtons)
button = nullptr; button = nullptr;
SetLabel( _("Timeline") ); SetLabel( XO("Timeline") );
SetName(GetLabel()); SetName();
SetBackgroundStyle(wxBG_STYLE_PAINT); SetBackgroundStyle(wxBG_STYLE_PAINT);
mLeftOffset = 0; mLeftOffset = 0;
@ -1066,7 +1066,7 @@ void AdornedRulerPanel::InvalidateRuler()
} }
namespace { namespace {
const wxString StartScrubbingMessage(const Scrubber &/*scrubber*/) const TranslatableString StartScrubbingMessage(const Scrubber &/*scrubber*/)
{ {
/* i18n-hint: These commands assist the user in finding a sound by ear. ... /* i18n-hint: These commands assist the user in finding a sound by ear. ...
"Scrubbing" is variable-speed playback, ... "Scrubbing" is variable-speed playback, ...
@ -1074,15 +1074,15 @@ namespace {
*/ */
#if 0 #if 0
if(scrubber.Seeks()) if(scrubber.Seeks())
return _("Click or drag to begin Seek"); return XO("Click or drag to begin Seek");
else else
return _("Click or drag to begin Scrub"); return XO("Click or drag to begin Scrub");
#else #else
return _("Click & move to Scrub. Click & drag to Seek."); return XO("Click & move to Scrub. Click & drag to Seek.");
#endif #endif
} }
const wxString ContinueScrubbingMessage( const TranslatableString ContinueScrubbingMessage(
const Scrubber &scrubber, bool clicked) const Scrubber &scrubber, bool clicked)
{ {
/* i18n-hint: These commands assist the user in finding a sound by ear. ... /* i18n-hint: These commands assist the user in finding a sound by ear. ...
@ -1091,26 +1091,26 @@ namespace {
*/ */
#if 0 #if 0
if(scrubber.Seeks()) if(scrubber.Seeks())
return _("Move to Seek"); return XO("Move to Seek");
else else
return _("Move to Scrub"); return XO("Move to Scrub");
#else #else
if( clicked ) { if( clicked ) {
// Since mouse is down, mention dragging first. // Since mouse is down, mention dragging first.
// IsScrubbing is true if Scrubbing OR seeking. // IsScrubbing is true if Scrubbing OR seeking.
if( scrubber.IsScrubbing() ) if( scrubber.IsScrubbing() )
// User is dragging already, explain. // User is dragging already, explain.
return _("Drag to Seek. Release to stop seeking."); return XO("Drag to Seek. Release to stop seeking.");
else else
// User has clicked but not yet moved or released. // User has clicked but not yet moved or released.
return _("Drag to Seek. Release and move to Scrub."); return XO("Drag to Seek. Release and move to Scrub.");
} }
// Since mouse is up, mention moving first. // Since mouse is up, mention moving first.
return _("Move to Scrub. Drag to Seek."); return XO("Move to Scrub. Drag to Seek.");
#endif #endif
} }
const wxString ScrubbingMessage(const Scrubber &scrubber, bool clicked) const TranslatableString ScrubbingMessage(const Scrubber &scrubber, bool clicked)
{ {
if (scrubber.HasMark()) if (scrubber.HasMark())
return ContinueScrubbingMessage(scrubber, clicked); return ContinueScrubbingMessage(scrubber, clicked);
@ -1501,10 +1501,10 @@ auto AdornedRulerPanel::ScrubbingHandle::Preview
auto message = ScrubbingMessage(scrubber, mClicked == Button::Left); auto message = ScrubbingMessage(scrubber, mClicked == Button::Left);
return { return {
message, message.Translation(),
{}, {},
// Tooltip is same as status message, or blank // Tooltip is same as status message, or blank
((mParent && mParent->mTimelineToolTip) ? message : wxString{}), ((mParent && mParent->mTimelineToolTip) ? message : TranslatableString{}),
}; };
} }
@ -1512,15 +1512,15 @@ auto AdornedRulerPanel::QPHandle::Preview
(const TrackPanelMouseState &state, const AudacityProject *pProject) (const TrackPanelMouseState &state, const AudacityProject *pProject)
-> HitTestPreview -> HitTestPreview
{ {
wxString tooltip; TranslatableString tooltip;
if (mParent && mParent->mTimelineToolTip) { if (mParent && mParent->mTimelineToolTip) {
if (!mParent->mQuickPlayEnabled) if (!mParent->mQuickPlayEnabled)
tooltip = _("Quick-Play disabled"); tooltip = XO("Quick-Play disabled");
else else
tooltip = _("Quick-Play enabled"); tooltip = XO("Quick-Play enabled");
} }
wxString message; TranslatableString message;
auto &scrubber = Scrubber::Get( *pProject ); auto &scrubber = Scrubber::Get( *pProject );
const bool scrubbing = scrubber.HasMark(); const bool scrubbing = scrubber.HasMark();
if (scrubbing) if (scrubbing)
@ -1543,7 +1543,7 @@ auto AdornedRulerPanel::QPHandle::Preview
state.state.m_x, mParent->mOldPlayRegion.GetEnd()); state.state.m_x, mParent->mOldPlayRegion.GetEnd());
return { return {
message, message.Translation(),
showArrows ? &cursorSizeWE : &cursorHand, showArrows ? &cursorSizeWE : &cursorHand,
tooltip, tooltip,
}; };

View File

@ -271,7 +271,8 @@ void CellularPanel::HandleMotion
auto oldCell = state.mLastCell.lock(); auto oldCell = state.mLastCell.lock();
auto oldHandle = Target(); auto oldHandle = Target();
wxString status{}, tooltip{}; wxString status{};
TranslatableString tooltip{};
wxCursor *pCursor{}; wxCursor *pCursor{};
unsigned refreshCode = 0; unsigned refreshCode = 0;
@ -373,7 +374,7 @@ void CellularPanel::HandleMotion
UpdateStatusMessage(status); UpdateStatusMessage(status);
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
if (tooltip != GetToolTipText()) { if (tooltip.Translation() != GetToolTipText()) {
// Unset first, by analogy with AButton // Unset first, by analogy with AButton
UnsetToolTip(); UnsetToolTip();
SetToolTip(tooltip); SetToolTip(tooltip);

View File

@ -12,6 +12,7 @@ Paul Licameli
#define __AUDACITY_HIT_TEST_RESULT__ #define __AUDACITY_HIT_TEST_RESULT__
#include "MemoryX.h" #include "MemoryX.h"
#include "Internat.h" // for TranslatableString
class wxCursor; class wxCursor;
@ -21,13 +22,13 @@ struct HitTestPreview
{} {}
HitTestPreview(const wxString &message_, wxCursor *cursor_, HitTestPreview(const wxString &message_, wxCursor *cursor_,
const wxString &tooltip_ = wxString{}) const TranslatableString &tooltip_ = {})
: message(message_), cursor(cursor_), tooltip(tooltip_) : message(message_), cursor(cursor_), tooltip{ tooltip_ }
{} {}
wxString message {}; wxString message {};
wxCursor *cursor {}; wxCursor *cursor {};
wxString tooltip{}; TranslatableString tooltip{};
}; };
#endif #endif

View File

@ -401,3 +401,5 @@ TranslatableString &TranslatableString::Join(
}; };
return *this; return *this;
} }
const TranslatableString InaudibleString{ wxT("\a") };

View File

@ -175,7 +175,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
mProject = project; mProject = project;
wxASSERT( pTrack ); wxASSERT( pTrack );
SetName(mTrack->GetName()); SetName( TranslatableString{ mTrack->GetName() } );
//this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); //this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
this->SetBackgroundColour( theTheme.Colour( clrMedium ) ); this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
@ -308,7 +308,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
false, // bool isInput false, // bool isInput
ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
MeterPanel::MixerTrackCluster); // Style style = HorizontalStereo, MeterPanel::MixerTrackCluster); // Style style = HorizontalStereo,
mMeter->SetName(_("Signal Level Meter")); mMeter->SetName(XO("Signal Level Meter"));
} }
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
@ -316,7 +316,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
mToggleButton_Mute->SetToolTip(_("Mute")); mToggleButton_Mute->SetToolTip(_("Mute"));
mToggleButton_Solo->SetToolTip(_("Solo")); mToggleButton_Solo->SetToolTip(_("Solo"));
if (GetWave()) if (GetWave())
mMeter->SetToolTip(_("Signal Level Meter")); mMeter->SetToolTip(XO("Signal Level Meter"));
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
UpdateForStateChange(); UpdateForStateChange();
@ -463,7 +463,7 @@ void MixerTrackCluster::UpdateForStateChange()
{ {
const wxString newName = mTrack->GetName(); const wxString newName = mTrack->GetName();
if (newName != GetName()) { if (newName != GetName()) {
SetName(newName); SetName( TranslatableString{ newName } );
mStaticText_TrackName->SetLabel(newName); mStaticText_TrackName->SetLabel(newName);
mStaticText_TrackName->SetName(newName); mStaticText_TrackName->SetName(newName);
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS

View File

@ -259,8 +259,8 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
#endif #endif
{ {
SetLayoutDirection(wxLayout_LeftToRight); SetLayoutDirection(wxLayout_LeftToRight);
SetLabel(_("Track Panel")); SetLabel(XO("Track Panel"));
SetName(_("Track Panel")); SetName(XO("Track Panel"));
SetBackgroundStyle(wxBG_STYLE_PAINT); SetBackgroundStyle(wxBG_STYLE_PAINT);
{ {

View File

@ -2567,8 +2567,8 @@ public:
: wxPanelWrapper(parent) : wxPanelWrapper(parent)
{ {
// This fools NVDA into not saying "Panel" when the dialog gets focus // This fools NVDA into not saying "Panel" when the dialog gets focus
SetName(wxT("\a")); SetName(InaudibleString);
SetLabel(wxT("\a")); SetLabel(InaudibleString);
mAcceptsFocus = true; mAcceptsFocus = true;
} }

View File

@ -30,7 +30,7 @@ END_EVENT_TABLE()
/// Constructor /// Constructor
BatchPrefs::BatchPrefs(wxWindow * parent, wxWindowID winid): BatchPrefs::BatchPrefs(wxWindow * parent, wxWindowID winid):
PrefsPanel(parent, winid, _("Batch")) PrefsPanel(parent, winid, XO("Batch"))
{ {
Populate(); Populate();
} }

View File

@ -53,7 +53,7 @@ BEGIN_EVENT_TABLE(DevicePrefs, PrefsPanel)
END_EVENT_TABLE() END_EVENT_TABLE()
DevicePrefs::DevicePrefs(wxWindow * parent, wxWindowID winid) DevicePrefs::DevicePrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Devices")) : PrefsPanel(parent, winid, XO("Devices"))
{ {
Populate(); Populate();
} }

View File

@ -49,7 +49,7 @@ END_EVENT_TABLE()
DirectoriesPrefs::DirectoriesPrefs(wxWindow * parent, wxWindowID winid) DirectoriesPrefs::DirectoriesPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: Directories, also called folders, in computer file systems */ /* i18n-hint: Directories, also called folders, in computer file systems */
: PrefsPanel(parent, winid, _("Directories")), : PrefsPanel(parent, winid, XO("Directories")),
mFreeSpace(NULL), mFreeSpace(NULL),
mTempDir(NULL) mTempDir(NULL)
{ {

View File

@ -31,7 +31,7 @@
#include "../ShuttleGui.h" #include "../ShuttleGui.h"
EffectsPrefs::EffectsPrefs(wxWindow * parent, wxWindowID winid) EffectsPrefs::EffectsPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Effects")) : PrefsPanel(parent, winid, XO("Effects"))
{ {
Populate(); Populate();
} }

View File

@ -60,7 +60,7 @@ END_EVENT_TABLE()
ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid) ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: Title of dialog governing "Extended", or "advanced," /* i18n-hint: Title of dialog governing "Extended", or "advanced,"
* audio file import options */ * audio file import options */
: PrefsPanel(parent, winid, _("Extended Import")), RuleTable(NULL), : PrefsPanel(parent, winid, XO("Extended Import")), RuleTable(NULL),
PluginList(NULL), mCreateTable (false), mDragFocus (NULL), PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1) mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1)
{ {

View File

@ -42,7 +42,7 @@ wxDEFINE_EVENT(EVT_LANGUAGE_CHANGE, wxCommandEvent);
GUIPrefs::GUIPrefs(wxWindow * parent, wxWindowID winid) GUIPrefs::GUIPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: refers to Audacity's user interface settings */ /* i18n-hint: refers to Audacity's user interface settings */
: PrefsPanel(parent, winid, _("Interface")) : PrefsPanel(parent, winid, XO("Interface"))
{ {
Populate(); Populate();
} }

View File

@ -25,7 +25,7 @@
#include "../ShuttleGui.h" #include "../ShuttleGui.h"
ImportExportPrefs::ImportExportPrefs(wxWindow * parent, wxWindowID winid) ImportExportPrefs::ImportExportPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Import / Export")) : PrefsPanel(parent, winid, XO("Import / Export"))
{ {
Populate(); Populate();
} }

View File

@ -83,7 +83,7 @@ END_EVENT_TABLE()
KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid, KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
const CommandID &name) const CommandID &name)
/* i18n-hint: as in computer keyboard (not musical!) */ /* i18n-hint: as in computer keyboard (not musical!) */
: PrefsPanel(parent, winid, _("Keyboard")), : PrefsPanel(parent, winid, XO("Keyboard")),
mView(NULL), mView(NULL),
mKey(NULL), mKey(NULL),
mFilter(NULL), mFilter(NULL),

View File

@ -47,7 +47,7 @@ END_EVENT_TABLE()
LibraryPrefs::LibraryPrefs(wxWindow * parent, wxWindowID winid) LibraryPrefs::LibraryPrefs(wxWindow * parent, wxWindowID winid)
/* i18-hint: refers to optional plug-in software libraries */ /* i18-hint: refers to optional plug-in software libraries */
: PrefsPanel(parent, winid, _("Libraries")) : PrefsPanel(parent, winid, XO("Libraries"))
{ {
Populate(); Populate();
} }

View File

@ -58,7 +58,7 @@ END_EVENT_TABLE()
MidiIOPrefs::MidiIOPrefs(wxWindow * parent, wxWindowID winid) MidiIOPrefs::MidiIOPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: untranslatable acronym for "Musical Instrument Device Interface" */ /* i18n-hint: untranslatable acronym for "Musical Instrument Device Interface" */
: PrefsPanel(parent, winid, _("MIDI Devices")) : PrefsPanel(parent, winid, XO("MIDI Devices"))
{ {
Populate(); Populate();
} }

View File

@ -29,7 +29,7 @@ with names like mnod-script-pipe that add NEW features.
/* i18n-hint: Modules are optional extensions to Audacity that add NEW features.*/ /* i18n-hint: Modules are optional extensions to Audacity that add NEW features.*/
ModulePrefs::ModulePrefs(wxWindow * parent, wxWindowID winid) ModulePrefs::ModulePrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Modules")) : PrefsPanel(parent, winid, XO("Modules"))
{ {
Populate(); Populate();
} }

View File

@ -61,7 +61,7 @@ enum
/// Constructor /// Constructor
MousePrefs::MousePrefs(wxWindow * parent, wxWindowID winid) MousePrefs::MousePrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Mouse")) : PrefsPanel(parent, winid, XO("Mouse"))
{ {
Populate(); Populate();
} }

View File

@ -28,7 +28,7 @@
#include "../Prefs.h" #include "../Prefs.h"
PlaybackPrefs::PlaybackPrefs(wxWindow * parent, wxWindowID winid) PlaybackPrefs::PlaybackPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Playback")) : PrefsPanel(parent, winid, XO("Playback"))
{ {
Populate(); Populate();
} }

View File

@ -52,7 +52,8 @@ class PrefsPanel /* not final */ : public wxPanelWrapper, ComponentInterface
using Factory = using Factory =
std::function< PrefsPanel * (wxWindow *parent, wxWindowID winid) >; std::function< PrefsPanel * (wxWindow *parent, wxWindowID winid) >;
PrefsPanel(wxWindow * parent, wxWindowID winid, const wxString &title) PrefsPanel(
wxWindow * parent, wxWindowID winid, const TranslatableString &title)
: wxPanelWrapper(parent, winid) : wxPanelWrapper(parent, winid)
{ {
SetLabel(title); // Provide visual label SetLabel(title); // Provide visual label

View File

@ -31,7 +31,7 @@ handling.
ProjectsPrefs::ProjectsPrefs(wxWindow * parent, wxWindowID winid) ProjectsPrefs::ProjectsPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, : PrefsPanel(parent, winid,
/* i18n-hint: (noun) i.e Audacity projects. */ /* i18n-hint: (noun) i.e Audacity projects. */
_("Projects")) XO("Projects"))
{ {
Populate(); Populate();
} }

View File

@ -57,7 +57,7 @@ END_EVENT_TABLE()
QualityPrefs::QualityPrefs(wxWindow * parent, wxWindowID winid) QualityPrefs::QualityPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: meaning accuracy in reproduction of sounds */ /* i18n-hint: meaning accuracy in reproduction of sounds */
: PrefsPanel(parent, winid, _("Quality")) : PrefsPanel(parent, winid, XO("Quality"))
{ {
Populate(); Populate();
} }

View File

@ -42,7 +42,7 @@ BEGIN_EVENT_TABLE(RecordingPrefs, PrefsPanel)
END_EVENT_TABLE() END_EVENT_TABLE()
RecordingPrefs::RecordingPrefs(wxWindow * parent, wxWindowID winid) RecordingPrefs::RecordingPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Recording")) : PrefsPanel(parent, winid, XO("Recording"))
{ {
gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &mUseCustomTrackName, false); gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &mUseCustomTrackName, false);
mOldNameChoice = mUseCustomTrackName; mOldNameChoice = mUseCustomTrackName;

View File

@ -38,7 +38,7 @@
#include "../widgets/AudacityMessageBox.h" #include "../widgets/AudacityMessageBox.h"
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt) SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt)
: PrefsPanel(parent, winid, wt ? _("Spectrogram Settings") : _("Spectrograms")) : PrefsPanel(parent, winid, wt ? XO("Spectrogram Settings") : XO("Spectrograms"))
, mWt(wt) , mWt(wt)
, mPopulating(false) , mPopulating(false)
{ {

View File

@ -63,7 +63,7 @@ ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid)
graphical user interface, including choices of colors, and similarity of images graphical user interface, including choices of colors, and similarity of images
such as those on button controls. Audacity can load and save alternative such as those on button controls. Audacity can load and save alternative
themes. */ themes. */
: PrefsPanel(parent, winid, _("Theme")) : PrefsPanel(parent, winid, XO("Theme"))
{ {
Populate(); Populate();
} }

View File

@ -24,7 +24,7 @@
TracksBehaviorsPrefs::TracksBehaviorsPrefs(wxWindow * parent, wxWindowID winid) TracksBehaviorsPrefs::TracksBehaviorsPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: i.e. the behaviors of tracks */ /* i18n-hint: i.e. the behaviors of tracks */
: PrefsPanel(parent, winid, _("Tracks Behaviors")) : PrefsPanel(parent, winid, XO("Tracks Behaviors"))
{ {
Populate(); Populate();
} }

View File

@ -218,7 +218,7 @@ TracksPrefs::TracksPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: "Tracks" include audio recordings but also other collections of /* i18n-hint: "Tracks" include audio recordings but also other collections of
* data associated with a time line, such as sequences of labels, and musical * data associated with a time line, such as sequences of labels, and musical
* notes */ * notes */
: PrefsPanel(parent, winid, _("Tracks")) : PrefsPanel(parent, winid, XO("Tracks"))
{ {
Populate(); Populate();
} }

View File

@ -27,7 +27,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
WarningsPrefs::WarningsPrefs(wxWindow * parent, wxWindowID winid) WarningsPrefs::WarningsPrefs(wxWindow * parent, wxWindowID winid)
: PrefsPanel(parent, winid, _("Warnings")) : PrefsPanel(parent, winid, XO("Warnings"))
{ {
Populate(); Populate();
} }

View File

@ -32,7 +32,7 @@ Paul Licameli
WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt) WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt)
/* i18n-hint: A waveform is a visual representation of vibration */ /* i18n-hint: A waveform is a visual representation of vibration */
: PrefsPanel(parent, winid, _("Waveforms")) : PrefsPanel(parent, winid, XO("Waveforms"))
, mWt(wt) , mWt(wt)
, mPopulating(false) , mPopulating(false)
{ {

View File

@ -105,7 +105,7 @@ static const TranslatableString
// gets written to prefs and cannot be changed in prefs to maintain backwards // gets written to prefs and cannot be changed in prefs to maintain backwards
// compatibility // compatibility
ControlToolBar::ControlToolBar( AudacityProject &project ) ControlToolBar::ControlToolBar( AudacityProject &project )
: ToolBar(project, TransportBarID, _("Transport"), wxT("Control")) : ToolBar(project, TransportBarID, XO("Transport"), wxT("Control"))
{ {
gPrefs->Read(wxT("/GUI/ErgonomicTransportButtons"), &mErgonomicTransportButtons, true); gPrefs->Read(wxT("/GUI/ErgonomicTransportButtons"), &mErgonomicTransportButtons, true);
mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT("")); mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
@ -343,7 +343,7 @@ void ControlToolBar::UpdatePrefs()
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Transport")); SetLabel(XO("Transport"));
// Give base class a chance // Give base class a chance
ToolBar::UpdatePrefs(); ToolBar::UpdatePrefs();

View File

@ -73,7 +73,7 @@ static int DeviceToolbarPrefsID()
//Standard contructor //Standard contructor
DeviceToolBar::DeviceToolBar( AudacityProject &project ) DeviceToolBar::DeviceToolBar( AudacityProject &project )
: ToolBar( project, DeviceBarID, _("Device"), wxT("Device"), true ) : ToolBar( project, DeviceBarID, XO("Device"), wxT("Device"), true )
{ {
wxTheApp->Bind( EVT_RESCANNED_DEVICES, wxTheApp->Bind( EVT_RESCANNED_DEVICES,
&DeviceToolBar::OnRescannedDevices, this ); &DeviceToolBar::OnRescannedDevices, this );
@ -324,7 +324,7 @@ void DeviceToolBar::UpdatePrefs()
RegenerateTooltips(); RegenerateTooltips();
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Device")); SetLabel(XO("Device"));
// Give base class a chance // Give base class a chance
ToolBar::UpdatePrefs(); ToolBar::UpdatePrefs();

View File

@ -78,7 +78,7 @@ END_EVENT_TABLE()
//Standard contructor //Standard contructor
EditToolBar::EditToolBar( AudacityProject &project ) EditToolBar::EditToolBar( AudacityProject &project )
: ToolBar(project, EditBarID, _("Edit"), wxT("Edit")) : ToolBar(project, EditBarID, XO("Edit"), wxT("Edit"))
{ {
} }
@ -206,7 +206,7 @@ void EditToolBar::UpdatePrefs()
RegenerateTooltips(); RegenerateTooltips();
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Edit")); SetLabel(XO("Edit"));
// Give base class a chance // Give base class a chance
ToolBar::UpdatePrefs(); ToolBar::UpdatePrefs();

View File

@ -49,15 +49,15 @@ END_EVENT_TABLE()
//Standard contructor //Standard contructor
MeterToolBar::MeterToolBar(AudacityProject &project, int type) MeterToolBar::MeterToolBar(AudacityProject &project, int type)
: ToolBar(project, type, _("Combined Meter"), wxT("CombinedMeter"), true) : ToolBar(project, type, XO("Combined Meter"), wxT("CombinedMeter"), true)
{ {
if( mType == RecordMeterBarID ){ if( mType == RecordMeterBarID ){
mWhichMeters = kWithRecordMeter; mWhichMeters = kWithRecordMeter;
mLabel = _("Recording Meter"); mLabel = XO("Recording Meter");
mSection = wxT("RecordMeter"); mSection = wxT("RecordMeter");
} else if( mType == PlayMeterBarID ){ } else if( mType == PlayMeterBarID ){
mWhichMeters = kWithPlayMeter; mWhichMeters = kWithPlayMeter;
mLabel = _("Playback Meter"); mLabel = XO("Playback Meter");
mSection = wxT("PlayMeter"); mSection = wxT("PlayMeter");
} else { } else {
mWhichMeters = kWithPlayMeter | kWithRecordMeter; mWhichMeters = kWithPlayMeter | kWithRecordMeter;
@ -126,11 +126,11 @@ void MeterToolBar::Populate()
wxDefaultPosition, wxDefaultPosition,
wxSize( 260, 28 ) ); wxSize( 260, 28 ) );
/* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.*/ /* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.*/
mRecordMeter->SetName( _("Record Meter")); mRecordMeter->SetName( XO("Record Meter"));
/* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded. /* i18n-hint: (noun) The meter that shows the loudness of the audio being recorded.
This is the name used in screen reader software, where having 'Meter' first This is the name used in screen reader software, where having 'Meter' first
apparently is helpful to partially sighted people. */ apparently is helpful to partially sighted people. */
mRecordMeter->SetLabel( _("Meter-Record") ); mRecordMeter->SetLabel( XO("Meter-Record") );
mSizer->Add( mRecordMeter, wxGBPosition( 0, 0 ), wxDefaultSpan, wxEXPAND ); mSizer->Add( mRecordMeter, wxGBPosition( 0, 0 ), wxDefaultSpan, wxEXPAND );
} }
@ -142,11 +142,11 @@ void MeterToolBar::Populate()
wxDefaultPosition, wxDefaultPosition,
wxSize( 260, 28 ) ); wxSize( 260, 28 ) );
/* i18n-hint: (noun) The meter that shows the loudness of the audio playing.*/ /* i18n-hint: (noun) The meter that shows the loudness of the audio playing.*/
mPlayMeter->SetName( _("Play Meter")); mPlayMeter->SetName( XO("Play Meter"));
/* i18n-hint: (noun) The meter that shows the loudness of the audio playing. /* i18n-hint: (noun) The meter that shows the loudness of the audio playing.
This is the name used in screen reader software, where having 'Meter' first This is the name used in screen reader software, where having 'Meter' first
apparently is helpful to partially sighted people. */ apparently is helpful to partially sighted people. */
mPlayMeter->SetLabel( _("Meter-Play")); mPlayMeter->SetLabel( XO("Meter-Play"));
mSizer->Add( mPlayMeter, wxGBPosition( (mWhichMeters & kWithRecordMeter)?1:0, 0 ), wxDefaultSpan, wxEXPAND ); mSizer->Add( mPlayMeter, wxGBPosition( (mWhichMeters & kWithRecordMeter)?1:0, 0 ), wxDefaultSpan, wxEXPAND );
} }
@ -158,7 +158,7 @@ void MeterToolBar::UpdatePrefs()
RegenerateTooltips(); RegenerateTooltips();
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Meter")); SetLabel(XO("Meter"));
// Give base class a chance // Give base class a chance
ToolBar::UpdatePrefs(); ToolBar::UpdatePrefs();
@ -168,9 +168,9 @@ void MeterToolBar::RegenerateTooltips()
{ {
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
if( mPlayMeter ) if( mPlayMeter )
mPlayMeter->SetToolTip( _("Playback Level") ); mPlayMeter->SetToolTip( XO("Playback Level") );
if( mRecordMeter ) if( mRecordMeter )
mRecordMeter->SetToolTip( _("Recording Level") ); mRecordMeter->SetToolTip( XO("Recording Level") );
#endif #endif
} }

View File

@ -56,7 +56,7 @@ END_EVENT_TABLE()
//Standard contructor //Standard contructor
MixerToolBar::MixerToolBar( AudacityProject &project ) MixerToolBar::MixerToolBar( AudacityProject &project )
: ToolBar(project, MixerBarID, _("Mixer"), wxT("Mixer"), true) : ToolBar(project, MixerBarID, XO("Mixer"), wxT("Mixer"), true)
{ {
mInputSliderVolume = 0.0; mInputSliderVolume = 0.0;
mOutputSliderVolume = 0.0; mOutputSliderVolume = 0.0;
@ -196,7 +196,7 @@ void MixerToolBar::UpdatePrefs()
#endif #endif
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Mixer")); SetLabel(XO("Mixer"));
RegenerateTooltips(); RegenerateTooltips();

View File

@ -57,7 +57,7 @@ END_EVENT_TABLE()
//Standard contructor //Standard contructor
ScrubbingToolBar::ScrubbingToolBar( AudacityProject &project ) ScrubbingToolBar::ScrubbingToolBar( AudacityProject &project )
: ToolBar(project, ScrubbingBarID, _("Scrub"), wxT("Scrub")) : ToolBar(project, ScrubbingBarID, XO("Scrub"), wxT("Scrub"))
{ {
} }
@ -135,7 +135,7 @@ void ScrubbingToolBar::UpdatePrefs()
RegenerateTooltips(); RegenerateTooltips();
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Scrubbing")); SetLabel(XO("Scrubbing"));
// Give base class a chance // Give base class a chance
ToolBar::UpdatePrefs(); ToolBar::UpdatePrefs();

View File

@ -108,7 +108,7 @@ BEGIN_EVENT_TABLE(SelectionBar, ToolBar)
END_EVENT_TABLE() END_EVENT_TABLE()
SelectionBar::SelectionBar( AudacityProject &project ) SelectionBar::SelectionBar( AudacityProject &project )
: ToolBar(project, SelectionBarID, _("Selection"), wxT("Selection")), : ToolBar(project, SelectionBarID, XO("Selection"), wxT("Selection")),
mListener(NULL), mRate(0.0), mListener(NULL), mRate(0.0),
mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0), mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0),
mDrive1( StartTimeID), mDrive2( EndTimeID ), mDrive1( StartTimeID), mDrive2( EndTimeID ),
@ -373,7 +373,7 @@ void SelectionBar::UpdatePrefs()
OnUpdate(e); OnUpdate(e);
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Selection")); SetLabel(XO("Selection"));
RegenerateTooltips(); RegenerateTooltips();
// Give base class a chance // Give base class a chance

View File

@ -96,7 +96,7 @@ static const wxString preferencePath
SpectralSelectionBar::SpectralSelectionBar( AudacityProject &project ) SpectralSelectionBar::SpectralSelectionBar( AudacityProject &project )
: ToolBar( project, : ToolBar( project,
SpectralSelectionBarID, _("Spectral Selection"), wxT("SpectralSelection") ) SpectralSelectionBarID, XO("Spectral Selection"), wxT("SpectralSelection") )
, mListener(NULL), mbCenterAndWidth(true) , mListener(NULL), mbCenterAndWidth(true)
, mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0) , mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0)
, mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL) , mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL)
@ -258,7 +258,7 @@ void SpectralSelectionBar::UpdatePrefs()
} }
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Spectral Selection")); SetLabel(XO("Spectral Selection"));
RegenerateTooltips(); RegenerateTooltips();

View File

@ -316,7 +316,7 @@ END_EVENT_TABLE()
// //
ToolBar::ToolBar( AudacityProject &project, ToolBar::ToolBar( AudacityProject &project,
int type, int type,
const wxString &label, const TranslatableString &label,
const wxString &section, const wxString &section,
bool resizable ) bool resizable )
: wxPanelWrapper() : wxPanelWrapper()
@ -349,16 +349,16 @@ ToolBar::~ToolBar()
// //
// Returns the toolbar title // Returns the toolbar title
// //
wxString ToolBar::GetTitle() TranslatableString ToolBar::GetTitle()
{ {
/* i18n-hint: %s will be replaced by the name of the kind of toolbar.*/ /* i18n-hint: %s will be replaced by the name of the kind of toolbar.*/
return wxString::Format( _("Audacity %s Toolbar"), GetLabel() ); return XO("Audacity %s Toolbar").Format( GetLabel() );
} }
// //
// Returns the toolbar label // Returns the toolbar label
// //
wxString ToolBar::GetLabel() TranslatableString ToolBar::GetLabel()
{ {
return mLabel; return mLabel;
} }
@ -384,6 +384,15 @@ int ToolBar::GetType()
// //
void ToolBar::SetLabel(const wxString & label) void ToolBar::SetLabel(const wxString & label)
{ {
// Probably shouldn't reach this overload, but perhaps virtual function
// dispatch will take us here from a pointer to the wxPanel base class
mLabel = TranslatableString{ label };
}
void ToolBar::SetLabel(const TranslatableString & label)
{
// Only this overload is publicly accessible when you have a pointer to
// Toolbar or a subclass of it
mLabel = label; mLabel = label;
} }

View File

@ -99,7 +99,7 @@ class ToolBar /* not final */
using Holder = wxWindowPtr<ToolBar>; using Holder = wxWindowPtr<ToolBar>;
ToolBar( AudacityProject &project, ToolBar( AudacityProject &project,
int type, const wxString & label, const wxString & section, int type, const TranslatableString & label, const wxString & section,
bool resizable = false); bool resizable = false);
virtual ~ToolBar(); virtual ~ToolBar();
@ -114,12 +114,15 @@ class ToolBar /* not final */
virtual void RegenerateTooltips() = 0; virtual void RegenerateTooltips() = 0;
int GetType(); int GetType();
wxString GetTitle(); TranslatableString GetTitle();
wxString GetLabel(); TranslatableString GetLabel();
wxString GetSection(); wxString GetSection();
ToolDock *GetDock(); ToolDock *GetDock();
private:
void SetLabel(const wxString & label) override; void SetLabel(const wxString & label) override;
public:
void SetLabel(const TranslatableString & label);
virtual void SetDocked(ToolDock *dock, bool pushed); virtual void SetDocked(ToolDock *dock, bool pushed);
// NEW virtual: // NEW virtual:
@ -222,7 +225,7 @@ class ToolBar /* not final */
protected: protected:
AudacityProject &mProject; AudacityProject &mProject;
wxString mLabel; TranslatableString mLabel;
wxString mSection; wxString mSection;
int mType; int mType;
private: private:

View File

@ -381,8 +381,8 @@ END_EVENT_TABLE()
ToolDock::ToolDock( ToolManager *manager, wxWindow *parent, int dockid ): ToolDock::ToolDock( ToolManager *manager, wxWindow *parent, int dockid ):
wxPanelWrapper( parent, dockid, wxDefaultPosition, parent->GetSize() ) wxPanelWrapper( parent, dockid, wxDefaultPosition, parent->GetSize() )
{ {
SetLabel( _( "ToolDock" ) ); SetLabel( XO( "ToolDock" ) );
SetName( _( "ToolDock" ) ); SetName( XO( "ToolDock" ) );
// Init // Init
mManager = manager; mManager = manager;

View File

@ -73,7 +73,7 @@ END_EVENT_TABLE()
//Standard constructor //Standard constructor
ToolsToolBar::ToolsToolBar( AudacityProject &project ) ToolsToolBar::ToolsToolBar( AudacityProject &project )
: ToolBar(project, ToolsBarID, _("Tools"), wxT("Tools")) : ToolBar(project, ToolsBarID, XO("Tools"), wxT("Tools"))
{ {
using namespace ToolCodes; using namespace ToolCodes;

View File

@ -96,7 +96,7 @@ END_EVENT_TABLE()
////Standard Constructor ////Standard Constructor
TranscriptionToolBar::TranscriptionToolBar( AudacityProject &project ) TranscriptionToolBar::TranscriptionToolBar( AudacityProject &project )
: ToolBar( project, : ToolBar( project,
TranscriptionBarID, _("Play-at-Speed"), wxT("Transcription"), true ) TranscriptionBarID, XO("Play-at-Speed"), wxT("Transcription"), true )
{ {
SetPlaySpeed( 1.0 * 100.0 ); SetPlaySpeed( 1.0 * 100.0 );
#ifdef EXPERIMENTAL_VOICE_DETECTION #ifdef EXPERIMENTAL_VOICE_DETECTION
@ -322,7 +322,7 @@ void TranscriptionToolBar::UpdatePrefs()
RegenerateTooltips(); RegenerateTooltips();
// Set label to pull in language change // Set label to pull in language change
SetLabel(_("Play-at-Speed")); SetLabel(XO("Play-at-Speed"));
// Give base class a chance // Give base class a chance
ToolBar::UpdatePrefs(); ToolBar::UpdatePrefs();

View File

@ -41,9 +41,9 @@ UIHandle::Result MuteButtonHandle::CommitChanges
return RefreshCode::RefreshNone; return RefreshCode::RefreshNone;
} }
wxString MuteButtonHandle::Tip(const wxMouseState &) const TranslatableString MuteButtonHandle::Tip(const wxMouseState &) const
{ {
auto name = _("Mute"); auto name = XO("Mute");
auto project = ::GetActiveProject(); auto project = ::GetActiveProject();
auto focused = auto focused =
TrackFocus::Get( *project ).Get() == GetTrack().get(); TrackFocus::Get( *project ).Get() == GetTrack().get();
@ -51,8 +51,10 @@ wxString MuteButtonHandle::Tip(const wxMouseState &) const
return name; return name;
auto &commandManager = CommandManager::Get( *project ); auto &commandManager = CommandManager::Get( *project );
TranslatedInternalString command{ wxT("TrackMute"), name }; TranslatedInternalString command{ wxT("TrackMute"), name.Translation() };
return commandManager.DescribeCommandsAndShortcuts(&command, 1u); return TranslatableString{
commandManager.DescribeCommandsAndShortcuts(&command, 1u)
};
} }
UIHandlePtr MuteButtonHandle::HitTest UIHandlePtr MuteButtonHandle::HitTest
@ -97,9 +99,9 @@ UIHandle::Result SoloButtonHandle::CommitChanges
return RefreshCode::RefreshNone; return RefreshCode::RefreshNone;
} }
wxString SoloButtonHandle::Tip(const wxMouseState &) const TranslatableString SoloButtonHandle::Tip(const wxMouseState &) const
{ {
auto name = _("Solo"); auto name = XO("Solo");
auto project = ::GetActiveProject(); auto project = ::GetActiveProject();
auto focused = auto focused =
TrackFocus::Get( *project ).Get() == GetTrack().get(); TrackFocus::Get( *project ).Get() == GetTrack().get();
@ -107,8 +109,10 @@ wxString SoloButtonHandle::Tip(const wxMouseState &) const
return name; return name;
auto &commandManager = CommandManager::Get( *project ); auto &commandManager = CommandManager::Get( *project );
TranslatedInternalString command{ wxT("TrackSolo"), name }; TranslatedInternalString command{ wxT("TrackSolo"), name.Translation() };
return commandManager.DescribeCommandsAndShortcuts( &command, 1u ); return TranslatableString{
commandManager.DescribeCommandsAndShortcuts( &command, 1u )
};
} }
UIHandlePtr SoloButtonHandle::HitTest UIHandlePtr SoloButtonHandle::HitTest

View File

@ -31,7 +31,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
override; override;
wxString Tip(const wxMouseState &state) const override; TranslatableString Tip(const wxMouseState &state) const override;
bool StopsOnKeystroke () override { return true; } bool StopsOnKeystroke () override { return true; }
@ -61,7 +61,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
override; override;
wxString Tip(const wxMouseState &state) const override; TranslatableString Tip(const wxMouseState &state) const override;
bool StopsOnKeystroke () override { return true; } bool StopsOnKeystroke () override { return true; }

View File

@ -75,7 +75,7 @@ HitTestPreview ButtonHandle::Preview
{ {
// No special cursor // No special cursor
auto message = Tip(st.state); auto message = Tip(st.state);
return { message, {}, message }; return { message.Translation(), {}, message };
} }
UIHandle::Result ButtonHandle::Release UIHandle::Result ButtonHandle::Release

View File

@ -17,6 +17,7 @@ class wxMouseEvent;
class wxMouseState; class wxMouseState;
class Track; class Track;
class TranslatableString;
/// \brief A UIHandle for a TrackPanel button, such as the Mute and Solo /// \brief A UIHandle for a TrackPanel button, such as the Mute and Solo
@ -45,7 +46,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) = 0; (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) = 0;
// Define a message for the status bar and tooltip. // Define a message for the status bar and tooltip.
virtual wxString Tip(const wxMouseState &state) const = 0; virtual TranslatableString Tip(const wxMouseState &state) const = 0;
void Enter(bool forward) final override; void Enter(bool forward) final override;

View File

@ -57,11 +57,11 @@ UIHandle::Result MinimizeButtonHandle::CommitChanges
return RefreshNone; return RefreshNone;
} }
wxString MinimizeButtonHandle::Tip(const wxMouseState &) const TranslatableString MinimizeButtonHandle::Tip(const wxMouseState &) const
{ {
auto pTrack = GetTrack(); auto pTrack = GetTrack();
return TrackView::Get( *pTrack ).GetMinimized() return TrackView::Get( *pTrack ).GetMinimized()
? _("Expand") : _("Collapse"); ? XO("Expand") : XO("Collapse");
} }
UIHandlePtr MinimizeButtonHandle::HitTest UIHandlePtr MinimizeButtonHandle::HitTest
@ -108,13 +108,13 @@ UIHandle::Result SelectButtonHandle::CommitChanges
return RefreshNone; return RefreshNone;
} }
wxString SelectButtonHandle::Tip(const wxMouseState &) const TranslatableString SelectButtonHandle::Tip(const wxMouseState &) const
{ {
auto pTrack = GetTrack(); auto pTrack = GetTrack();
#if defined(__WXMAC__) #if defined(__WXMAC__)
return pTrack->GetSelected() ? _("Command+Click to Unselect") : _("Select track"); return pTrack->GetSelected() ? XO("Command+Click to Unselect") : XO("Select track");
#else #else
return pTrack->GetSelected() ? _("Ctrl+Click to Unselect") : _("Select track"); return pTrack->GetSelected() ? XO("Ctrl+Click to Unselect") : XO("Select track");
#endif #endif
} }
@ -170,9 +170,9 @@ UIHandle::Result CloseButtonHandle::CommitChanges
return result; return result;
} }
wxString CloseButtonHandle::Tip(const wxMouseState &) const TranslatableString CloseButtonHandle::Tip(const wxMouseState &) const
{ {
auto name = _("Close"); auto name = XO("Close");
auto project = ::GetActiveProject(); auto project = ::GetActiveProject();
auto focused = auto focused =
TrackFocus::Get( *project ).Get() == GetTrack().get(); TrackFocus::Get( *project ).Get() == GetTrack().get();
@ -180,8 +180,10 @@ wxString CloseButtonHandle::Tip(const wxMouseState &) const
return name; return name;
auto &commandManager = CommandManager::Get( *project ); auto &commandManager = CommandManager::Get( *project );
TranslatedInternalString command{ wxT("TrackClose"), name }; TranslatedInternalString command{ wxT("TrackClose"), name.Translation() };
return commandManager.DescribeCommandsAndShortcuts( &command, 1u ); return TranslatableString{
commandManager.DescribeCommandsAndShortcuts( &command, 1u )
};
} }
UIHandlePtr CloseButtonHandle::HitTest UIHandlePtr CloseButtonHandle::HitTest
@ -230,9 +232,9 @@ UIHandle::Result MenuButtonHandle::CommitChanges
return RefreshCode::RefreshNone; return RefreshCode::RefreshNone;
} }
wxString MenuButtonHandle::Tip(const wxMouseState &) const TranslatableString MenuButtonHandle::Tip(const wxMouseState &) const
{ {
auto name = _("Open menu..."); auto name = XO("Open menu...");
auto project = ::GetActiveProject(); auto project = ::GetActiveProject();
auto focused = auto focused =
TrackFocus::Get( *project ).Get() == GetTrack().get(); TrackFocus::Get( *project ).Get() == GetTrack().get();
@ -240,8 +242,10 @@ wxString MenuButtonHandle::Tip(const wxMouseState &) const
return name; return name;
auto &commandManager = CommandManager::Get( *project ); auto &commandManager = CommandManager::Get( *project );
TranslatedInternalString command{ wxT("TrackMenu"), name }; TranslatedInternalString command{ wxT("TrackMenu"), name.Translation() };
return commandManager.DescribeCommandsAndShortcuts( &command, 1u ); return TranslatableString{
commandManager.DescribeCommandsAndShortcuts( &command, 1u )
};
} }
UIHandlePtr MenuButtonHandle::HitTest UIHandlePtr MenuButtonHandle::HitTest

View File

@ -24,7 +24,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
override; override;
wxString Tip(const wxMouseState &state) const override; TranslatableString Tip(const wxMouseState &state) const override;
public: public:
explicit MinimizeButtonHandle explicit MinimizeButtonHandle
@ -49,7 +49,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
override; override;
wxString Tip(const wxMouseState &state) const override; TranslatableString Tip(const wxMouseState &state) const override;
public: public:
explicit SelectButtonHandle explicit SelectButtonHandle
@ -74,7 +74,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
override; override;
wxString Tip(const wxMouseState &state) const override; TranslatableString Tip(const wxMouseState &state) const override;
bool StopsOnKeystroke () override { return true; } bool StopsOnKeystroke () override { return true; }
@ -102,7 +102,7 @@ protected:
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
override; override;
wxString Tip(const wxMouseState &state) const override; TranslatableString Tip(const wxMouseState &state) const override;
public: public:
explicit MenuButtonHandle explicit MenuButtonHandle

View File

@ -35,17 +35,16 @@ Paul Licameli split from TrackPanel.cpp
#endif #endif
namespace { namespace {
wxString Message(unsigned trackCount) { TranslatableString Message(unsigned trackCount) {
if (trackCount > 1) if (trackCount > 1)
// i18n-hint: %s is replaced by (translation of) 'Ctrl-Click' on windows, 'Command-Click' on Mac // i18n-hint: %s is replaced by (translation of) 'Ctrl-Click' on windows, 'Command-Click' on Mac
return wxString::Format( return XO(
_("%s to select or deselect track. Drag up or down to change track order."), "%s to select or deselect track. Drag up or down to change track order.")
CTRL_CLICK ); .Format( CTRL_CLICK );
else else
// i18n-hint: %s is replaced by (translation of) 'Ctrl-Click' on windows, 'Command-Click' on Mac // i18n-hint: %s is replaced by (translation of) 'Ctrl-Click' on windows, 'Command-Click' on Mac
return wxString::Format( return XO("%s to select or deselect track.")
_("%s to select or deselect track."), .Format( CTRL_CLICK );
CTRL_CLICK );
} }
} }
@ -157,7 +156,7 @@ HitTestPreview TrackSelectHandle::Preview
const bool unsafe = const bool unsafe =
ProjectAudioIO::Get( *GetActiveProject() ).IsAudioActive(); ProjectAudioIO::Get( *GetActiveProject() ).IsAudioActive();
return { return {
message, message.Translation(),
(unsafe (unsafe
? &*disabledCursor ? &*disabledCursor
: &*rearrangeCursor) : &*rearrangeCursor)
@ -169,7 +168,7 @@ HitTestPreview TrackSelectHandle::Preview
// Don't test safety, because the click to change selection is allowed // Don't test safety, because the click to change selection is allowed
static wxCursor arrowCursor{ wxCURSOR_ARROW }; static wxCursor arrowCursor{ wxCURSOR_ARROW };
return { return {
message, message.Translation(),
&arrowCursor, &arrowCursor,
message message
}; };

View File

@ -106,6 +106,10 @@ void Grabber::SetAsSpacer( bool bIsSpacer ) {
mAsSpacer = bIsSpacer; mAsSpacer = bIsSpacer;
}; };
void Grabber::SetToolTip(TranslatableString toolTip)
{
wxWindow::SetToolTip( toolTip.Strip().Translation() );
}
// //
// Draw the grabber // Draw the grabber
@ -215,7 +219,7 @@ void Grabber::OnEnter(wxMouseEvent & WXUNUSED(event))
// to make it pop up when we want it. // to make it pop up when we want it.
const auto text = GetToolTipText(); const auto text = GetToolTipText();
UnsetToolTip(); UnsetToolTip();
SetToolTip(text); wxWindow::SetToolTip(text);
if( mAsSpacer ) if( mAsSpacer )
return; return;

View File

@ -34,6 +34,8 @@ flicker-free use.
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/statbmp.h> // to inherit #include <wx/statbmp.h> // to inherit
class TranslatableString;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Grabber Class /// Grabber Class
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -116,6 +118,9 @@ class Grabber final : public wxWindow
void PushButton(bool state); void PushButton(bool state);
void SetAsSpacer( bool bIsSpacer ); void SetAsSpacer( bool bIsSpacer );
// overload and hide the inherited function that takes naked wxString:
void SetToolTip(TranslatableString toolTip);
protected: protected:
void OnLeftDown(wxMouseEvent & event); void OnLeftDown(wxMouseEvent & event);

View File

@ -319,7 +319,7 @@ MeterPanel::MeterPanel(AudacityProject *project,
mAccSilent(false) mAccSilent(false)
{ {
// i18n-hint: Noun (the meter is used for playback or record level monitoring) // i18n-hint: Noun (the meter is used for playback or record level monitoring)
SetName( _("Meter") ); SetName( XO("Meter") );
// Suppress warnings about the header file // Suppress warnings about the header file
wxUnusedVar(SpeakerMenu_xpm); wxUnusedVar(SpeakerMenu_xpm);
wxUnusedVar(MicMenu_xpm); wxUnusedVar(MicMenu_xpm);

View File

@ -38,6 +38,26 @@ void wxTabTraversalWrapperCharHook(wxKeyEvent &event)
event.Skip(); event.Skip();
} }
void wxPanelWrapper::SetLabel(const TranslatableString & label)
{
wxPanel::SetLabel( label.Translation() );
}
void wxPanelWrapper::SetName(const TranslatableString & name)
{
wxPanel::SetName( name.Translation() );
}
void wxPanelWrapper::SetToolTip(TranslatableString toolTip)
{
wxPanel::SetToolTip( toolTip.Strip().Translation() );
}
void wxPanelWrapper::SetName()
{
wxPanel::SetName( GetLabel() );
}
void wxDialogWrapper::SetTitle(const TranslatableString & title) void wxDialogWrapper::SetTitle(const TranslatableString & title)
{ {
wxDialog::SetTitle( title.Translation() ); wxDialog::SetTitle( title.Translation() );

View File

@ -50,8 +50,9 @@ public:
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER, long style = wxTAB_TRAVERSAL | wxNO_BORDER,
// Important: default window name localizes! // Important: default window name localizes!
const wxString& name = _("Panel")) const TranslatableString& name = XO("Panel"))
: wxTabTraversalWrapper<wxPanel> ( parent, winid, pos, size, style, name ) : wxTabTraversalWrapper<wxPanel> (
parent, winid, pos, size, style, name.Translation() )
{} {}
// Pseudo ctor // Pseudo ctor
@ -62,12 +63,18 @@ public:
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER, long style = wxTAB_TRAVERSAL | wxNO_BORDER,
// Important: default window name localizes! // Important: default window name localizes!
const wxString& name = _("Panel")) const TranslatableString& name = XO("Panel"))
{ {
return wxTabTraversalWrapper<wxPanel>::Create( return wxTabTraversalWrapper<wxPanel>::Create(
parent, winid, pos, size, style, name parent, winid, pos, size, style, name.Translation()
); );
} }
// overload and hide the inherited functions that take naked wxString:
void SetLabel(const TranslatableString & label);
void SetName(const TranslatableString & name);
void SetToolTip(TranslatableString toolTip);
// Set the name to equal the label:
void SetName();
}; };
class AUDACITY_DLL_API wxDialogWrapper : public wxTabTraversalWrapper<wxDialog> class AUDACITY_DLL_API wxDialogWrapper : public wxTabTraversalWrapper<wxDialog>