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
}
void TrackPanelAx::MessageForScreenReader(const wxString& message)
void TrackPanelAx::MessageForScreenReader(const TranslatableString& message)
{
#if wxUSE_ACCESSIBILITY
if (GetWindow() == wxWindow::FindFocus())
@ -227,7 +227,7 @@ void TrackPanelAx::MessageForScreenReader(const wxString& message)
auto t = GetFocus();
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.
// This ensures that screen readers read it.
@ -788,7 +788,7 @@ void TrackFocus::SetAccessible(
#endif
}
void TrackFocus::MessageForScreenReader(const wxString& message)
void TrackFocus::MessageForScreenReader(const TranslatableString& message)
{
if (mAx)
mAx->MessageForScreenReader( message );

View File

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

View File

@ -307,14 +307,15 @@ int FindClipBoundaries
}
// 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) {
auto longName = result.ComposeTrackName();
wxString str;
TranslatableString str;
auto nClips = result.waveTrack->GetNumClips();
if (result.nFound < 2) {
/* i18n-hint: in the string after this one,
@ -336,7 +337,7 @@ wxString ClipBoundaryMessage(const std::vector<FoundClipBoundary>& results)
result.index1 + 1,
nClips,
longName
).Translation();
);
}
else {
/* i18n-hint: in the string after this one,
@ -360,13 +361,13 @@ wxString ClipBoundaryMessage(const std::vector<FoundClipBoundary>& results)
result.index2 + 1,
nClips,
longName
).Translation();
);
}
if (message.empty())
message = str;
else
message = wxString::Format(_("%s, %s"), message, str);
message = XO("%s, %s").Format( message, str );
}
return message;
@ -391,7 +392,7 @@ void DoSelectClipBoundary(AudacityProject &project, bool next)
ProjectHistory::Get( project ).ModifyState(false);
wxString message = ClipBoundaryMessage(results);
auto message = ClipBoundaryMessage(results);
trackFocus.MessageForScreenReader(message);
}
}
@ -576,7 +577,7 @@ void DoSelectClip(AudacityProject &project, bool next)
window.ScrollIntoView(selectedRegion.t0());
// create and send message to screen reader
wxString message;
TranslatableString message;
for (auto& result : results) {
auto longName = result.ComposeTrackName();
auto nClips = result.waveTrack->GetNumClips();
@ -593,12 +594,12 @@ void DoSelectClip(AudacityProject &project, bool next)
result.index + 1,
nClips,
longName
).Translation();
);
if (message.empty())
message = str;
else
message = wxString::Format(_("%s, %s"), message, str);
message = XO("%s, %s").Format( message, str );
}
trackFocus.MessageForScreenReader(message);
}
@ -623,7 +624,7 @@ void DoCursorClipBoundary
ProjectHistory::Get( project ).ModifyState(false);
window.ScrollIntoView(selectedRegion.t0());
wxString message = ClipBoundaryMessage(results);
auto message = ClipBoundaryMessage(results);
trackFocus.MessageForScreenReader(message);
}
}
@ -726,7 +727,7 @@ void DoClipLeftOrRight
}
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();
if (nLabelTrack == 0 ) {
trackFocus.MessageForScreenReader(_("no label track"));
trackFocus.MessageForScreenReader(XO("no label track"));
}
else if (nLabelTrack > 1) {
// 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>();
if (!lt)
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
@ -180,13 +180,12 @@ void DoMoveToLabel(AudacityProject &project, bool next)
window.RedrawProject();
}
wxString message;
message.Printf(
wxT("%s %d of %d"), label->title, i + 1, lt->GetNumLabels() );
auto message = XO("%s %d of %d")
.Format( label->title, i + 1, lt->GetNumLabels() );
trackFocus.MessageForScreenReader(message);
}
else {
trackFocus.MessageForScreenReader(_("no labels in label track"));
trackFocus.MessageForScreenReader(XO("no labels in label track"));
}
}
}