1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-30 23:49:28 +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>;
// A special string value that will have no screen reader pronunciation
extern const TranslatableString InaudibleString;
// For using std::unordered_map on TranslatableString
// Note: hashing on msgids only, which is not all of the information
namespace std

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,7 +60,7 @@ END_EVENT_TABLE()
ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid)
/* i18n-hint: Title of dialog governing "Extended", or "advanced,"
* 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),
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)
/* i18n-hint: refers to Audacity's user interface settings */
: PrefsPanel(parent, winid, _("Interface"))
: PrefsPanel(parent, winid, XO("Interface"))
{
Populate();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,8 @@ class PrefsPanel /* not final */ : public wxPanelWrapper, ComponentInterface
using Factory =
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)
{
SetLabel(title); // Provide visual label

View File

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

View File

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

View File

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

View File

@ -38,7 +38,7 @@
#include "../widgets/AudacityMessageBox.h"
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)
, 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
such as those on button controls. Audacity can load and save alternative
themes. */
: PrefsPanel(parent, winid, _("Theme"))
: PrefsPanel(parent, winid, XO("Theme"))
{
Populate();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,7 +78,7 @@ END_EVENT_TABLE()
//Standard contructor
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();
// Set label to pull in language change
SetLabel(_("Edit"));
SetLabel(XO("Edit"));
// Give base class a chance
ToolBar::UpdatePrefs();

View File

@ -49,15 +49,15 @@ END_EVENT_TABLE()
//Standard contructor
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 ){
mWhichMeters = kWithRecordMeter;
mLabel = _("Recording Meter");
mLabel = XO("Recording Meter");
mSection = wxT("RecordMeter");
} else if( mType == PlayMeterBarID ){
mWhichMeters = kWithPlayMeter;
mLabel = _("Playback Meter");
mLabel = XO("Playback Meter");
mSection = wxT("PlayMeter");
} else {
mWhichMeters = kWithPlayMeter | kWithRecordMeter;
@ -126,11 +126,11 @@ void MeterToolBar::Populate()
wxDefaultPosition,
wxSize( 260, 28 ) );
/* 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.
This is the name used in screen reader software, where having 'Meter' first
apparently is helpful to partially sighted people. */
mRecordMeter->SetLabel( _("Meter-Record") );
mRecordMeter->SetLabel( XO("Meter-Record") );
mSizer->Add( mRecordMeter, wxGBPosition( 0, 0 ), wxDefaultSpan, wxEXPAND );
}
@ -142,11 +142,11 @@ void MeterToolBar::Populate()
wxDefaultPosition,
wxSize( 260, 28 ) );
/* 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.
This is the name used in screen reader software, where having 'Meter' first
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 );
}
@ -158,7 +158,7 @@ void MeterToolBar::UpdatePrefs()
RegenerateTooltips();
// Set label to pull in language change
SetLabel(_("Meter"));
SetLabel(XO("Meter"));
// Give base class a chance
ToolBar::UpdatePrefs();
@ -168,9 +168,9 @@ void MeterToolBar::RegenerateTooltips()
{
#if wxUSE_TOOLTIPS
if( mPlayMeter )
mPlayMeter->SetToolTip( _("Playback Level") );
mPlayMeter->SetToolTip( XO("Playback Level") );
if( mRecordMeter )
mRecordMeter->SetToolTip( _("Recording Level") );
mRecordMeter->SetToolTip( XO("Recording Level") );
#endif
}

View File

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

View File

@ -57,7 +57,7 @@ END_EVENT_TABLE()
//Standard contructor
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();
// Set label to pull in language change
SetLabel(_("Scrubbing"));
SetLabel(XO("Scrubbing"));
// Give base class a chance
ToolBar::UpdatePrefs();

View File

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

View File

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

View File

@ -316,7 +316,7 @@ END_EVENT_TABLE()
//
ToolBar::ToolBar( AudacityProject &project,
int type,
const wxString &label,
const TranslatableString &label,
const wxString &section,
bool resizable )
: wxPanelWrapper()
@ -349,16 +349,16 @@ ToolBar::~ToolBar()
//
// Returns the toolbar title
//
wxString ToolBar::GetTitle()
TranslatableString ToolBar::GetTitle()
{
/* 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
//
wxString ToolBar::GetLabel()
TranslatableString ToolBar::GetLabel()
{
return mLabel;
}
@ -384,6 +384,15 @@ int ToolBar::GetType()
//
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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@ class wxMouseEvent;
class wxMouseState;
class Track;
class TranslatableString;
/// \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;
// 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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,6 +38,26 @@ void wxTabTraversalWrapperCharHook(wxKeyEvent &event)
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)
{
wxDialog::SetTitle( title.Translation() );

View File

@ -50,8 +50,9 @@ public:
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
// Important: default window name localizes!
const wxString& name = _("Panel"))
: wxTabTraversalWrapper<wxPanel> ( parent, winid, pos, size, style, name )
const TranslatableString& name = XO("Panel"))
: wxTabTraversalWrapper<wxPanel> (
parent, winid, pos, size, style, name.Translation() )
{}
// Pseudo ctor
@ -62,12 +63,18 @@ public:
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
// Important: default window name localizes!
const wxString& name = _("Panel"))
const TranslatableString& name = XO("Panel"))
{
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>