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

MessageForScreenReader takes TranslatableString

This commit is contained in:
Paul Licameli 2019-12-23 15:05:27 -05:00
parent d1637c22c0
commit 8792e08bb9
4 changed files with 23 additions and 23 deletions

View File

@ -219,7 +219,7 @@ void TrackPanelAx::Updated()
#endif #endif
} }
void TrackPanelAx::MessageForScreenReader(const wxString& message) void TrackPanelAx::MessageForScreenReader(const TranslatableString& message)
{ {
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
if (GetWindow() == wxWindow::FindFocus()) if (GetWindow() == wxWindow::FindFocus())
@ -227,7 +227,7 @@ void TrackPanelAx::MessageForScreenReader(const wxString& message)
auto t = GetFocus(); auto t = GetFocus();
int childId = t ? TrackNum(t) : 0; int childId = t ? TrackNum(t) : 0;
mMessage = message; mMessage = message.Translation();
// append \a alernatively, so that the string is never the same as the previous string. // append \a alernatively, so that the string is never the same as the previous string.
// This ensures that screen readers read it. // This ensures that screen readers read it.
@ -788,7 +788,7 @@ void TrackFocus::SetAccessible(
#endif #endif
} }
void TrackFocus::MessageForScreenReader(const wxString& message) void TrackFocus::MessageForScreenReader(const TranslatableString& message)
{ {
if (mAx) if (mAx)
mAx->MessageForScreenReader( message ); mAx->MessageForScreenReader( message );

View File

@ -63,7 +63,7 @@ public:
// Called to signal changes to a track // Called to signal changes to a track
void Updated(); void Updated();
void MessageForScreenReader(const wxString& message); void MessageForScreenReader(const TranslatableString& message);
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
// Retrieves the address of an IDispatch interface for the specified child. // Retrieves the address of an IDispatch interface for the specified child.
@ -186,7 +186,7 @@ public:
void SetAccessible( wxWindow &owner, void SetAccessible( wxWindow &owner,
std::unique_ptr< TrackPanelAx > pAccessible ); std::unique_ptr< TrackPanelAx > pAccessible );
void MessageForScreenReader(const wxString& message); void MessageForScreenReader(const TranslatableString& message);
void UpdateAccessibility(); void UpdateAccessibility();

View File

@ -307,14 +307,15 @@ int FindClipBoundaries
} }
// for clip boundary commands, create a message for screen readers // for clip boundary commands, create a message for screen readers
wxString ClipBoundaryMessage(const std::vector<FoundClipBoundary>& results) TranslatableString ClipBoundaryMessage(
const std::vector<FoundClipBoundary>& results)
{ {
wxString message; TranslatableString message;
for (auto& result : results) { for (auto& result : results) {
auto longName = result.ComposeTrackName(); auto longName = result.ComposeTrackName();
wxString str; TranslatableString str;
auto nClips = result.waveTrack->GetNumClips(); auto nClips = result.waveTrack->GetNumClips();
if (result.nFound < 2) { if (result.nFound < 2) {
/* i18n-hint: in the string after this one, /* i18n-hint: in the string after this one,
@ -336,7 +337,7 @@ wxString ClipBoundaryMessage(const std::vector<FoundClipBoundary>& results)
result.index1 + 1, result.index1 + 1,
nClips, nClips,
longName longName
).Translation(); );
} }
else { else {
/* i18n-hint: in the string after this one, /* i18n-hint: in the string after this one,
@ -360,13 +361,13 @@ wxString ClipBoundaryMessage(const std::vector<FoundClipBoundary>& results)
result.index2 + 1, result.index2 + 1,
nClips, nClips,
longName longName
).Translation(); );
} }
if (message.empty()) if (message.empty())
message = str; message = str;
else else
message = wxString::Format(_("%s, %s"), message, str); message = XO("%s, %s").Format( message, str );
} }
return message; return message;
@ -391,7 +392,7 @@ void DoSelectClipBoundary(AudacityProject &project, bool next)
ProjectHistory::Get( project ).ModifyState(false); ProjectHistory::Get( project ).ModifyState(false);
wxString message = ClipBoundaryMessage(results); auto message = ClipBoundaryMessage(results);
trackFocus.MessageForScreenReader(message); trackFocus.MessageForScreenReader(message);
} }
} }
@ -576,7 +577,7 @@ void DoSelectClip(AudacityProject &project, bool next)
window.ScrollIntoView(selectedRegion.t0()); window.ScrollIntoView(selectedRegion.t0());
// create and send message to screen reader // create and send message to screen reader
wxString message; TranslatableString message;
for (auto& result : results) { for (auto& result : results) {
auto longName = result.ComposeTrackName(); auto longName = result.ComposeTrackName();
auto nClips = result.waveTrack->GetNumClips(); auto nClips = result.waveTrack->GetNumClips();
@ -593,12 +594,12 @@ void DoSelectClip(AudacityProject &project, bool next)
result.index + 1, result.index + 1,
nClips, nClips,
longName longName
).Translation(); );
if (message.empty()) if (message.empty())
message = str; message = str;
else else
message = wxString::Format(_("%s, %s"), message, str); message = XO("%s, %s").Format( message, str );
} }
trackFocus.MessageForScreenReader(message); trackFocus.MessageForScreenReader(message);
} }
@ -623,7 +624,7 @@ void DoCursorClipBoundary
ProjectHistory::Get( project ).ModifyState(false); ProjectHistory::Get( project ).ModifyState(false);
window.ScrollIntoView(selectedRegion.t0()); window.ScrollIntoView(selectedRegion.t0());
wxString message = ClipBoundaryMessage(results); auto message = ClipBoundaryMessage(results);
trackFocus.MessageForScreenReader(message); trackFocus.MessageForScreenReader(message);
} }
} }
@ -726,7 +727,7 @@ void DoClipLeftOrRight
} }
if ( amount == 0.0 ) if ( amount == 0.0 )
trackFocus.MessageForScreenReader( _("clip not moved")); trackFocus.MessageForScreenReader( XO("clip not moved"));
} }
} }

View File

@ -145,7 +145,7 @@ void DoMoveToLabel(AudacityProject &project, bool next)
auto nLabelTrack = trackRange.size(); auto nLabelTrack = trackRange.size();
if (nLabelTrack == 0 ) { if (nLabelTrack == 0 ) {
trackFocus.MessageForScreenReader(_("no label track")); trackFocus.MessageForScreenReader(XO("no label track"));
} }
else if (nLabelTrack > 1) { else if (nLabelTrack > 1) {
// find first label track, if any, starting at the focused track // find first label track, if any, starting at the focused track
@ -153,7 +153,7 @@ void DoMoveToLabel(AudacityProject &project, bool next)
*tracks.Find(trackFocus.Get()).Filter<LabelTrack>(); *tracks.Find(trackFocus.Get()).Filter<LabelTrack>();
if (!lt) if (!lt)
trackFocus.MessageForScreenReader( trackFocus.MessageForScreenReader(
_("no label track at or below focused track")); XO("no label track at or below focused track"));
} }
// If there is a single label track, or there is a label track at or below // If there is a single label track, or there is a label track at or below
@ -180,13 +180,12 @@ void DoMoveToLabel(AudacityProject &project, bool next)
window.RedrawProject(); window.RedrawProject();
} }
wxString message; auto message = XO("%s %d of %d")
message.Printf( .Format( label->title, i + 1, lt->GetNumLabels() );
wxT("%s %d of %d"), label->title, i + 1, lt->GetNumLabels() );
trackFocus.MessageForScreenReader(message); trackFocus.MessageForScreenReader(message);
} }
else { else {
trackFocus.MessageForScreenReader(_("no labels in label track")); trackFocus.MessageForScreenReader(XO("no labels in label track"));
} }
} }
} }