1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 22:12:58 +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

@@ -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
};