diff --git a/source/appModules/kindle.py b/source/appModules/kindle.py index 5c3241663b1..6b9ef327634 100644 --- a/source/appModules/kindle.py +++ b/source/appModules/kindle.py @@ -137,8 +137,7 @@ def script_showSelectionOptions(self, gesture): # so retrieve and report the selection from Kindle. # we can't just use self.makeTextInfo, as that will use our fake selection. realSel = self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION) - # Translators: Announces selected text. %s is replaced with the text. - speech.speakSelectionMessage(_("selected %s"), realSel.text) + speech.speakSelectedText(realSel.text) # Remove our virtual selection and move the caret to the active end. fakeSel.innerTextInfo = realSel fakeSel.collapse(end=not self._lastSelectionMovedStart) diff --git a/source/appModules/powerpnt.py b/source/appModules/powerpnt.py index 9d169bc65ff..373148524af 100644 --- a/source/appModules/powerpnt.py +++ b/source/appModules/powerpnt.py @@ -1081,7 +1081,7 @@ def event_treeInterceptor_gainFocus(self): else: info = self.selection if not info.isCollapsed: - speech.speakSelectionMessage(_("selected %s"), info.text) + speech.speakSelectedText(info.text) else: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE) diff --git a/source/browseMode.py b/source/browseMode.py index ae969d34a13..0d789d21482 100644 --- a/source/browseMode.py +++ b/source/browseMode.py @@ -1221,7 +1221,7 @@ def event_treeInterceptor_gainFocus(self): speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS) info = self.selection if not info.isCollapsed: - speech.speakSelectionMessage(_("selected %s"), info.text) + speech.speakSelectedText(info.text) else: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, reason=controlTypes.REASON_CARET, unit=textInfos.UNIT_LINE) diff --git a/source/compoundDocuments.py b/source/compoundDocuments.py index 360609c5fc7..1bceece602b 100644 --- a/source/compoundDocuments.py +++ b/source/compoundDocuments.py @@ -446,7 +446,7 @@ def event_treeInterceptor_gainFocus(self): info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=controlTypes.REASON_CARET) else: - speech.speakSelectionMessage(_("selected %s"), info.text) + speech.speakSelectedText(info.text) braille.handler.handleGainFocus(self) self.initAutoSelectDetection() diff --git a/source/globalCommands.py b/source/globalCommands.py index c311d2cb6ea..b17d8b9ff0c 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -210,7 +210,7 @@ def script_reportCurrentSelection(self,gesture): if not info or info.isCollapsed: speech.speakMessage(_("No selection")) else: - speech.speakMessage(_("Selected %s")%info.text) + speech.speakSelectedText(info.text) # Translators: Input help mode message for report current selection command. script_reportCurrentSelection.__doc__=_("Announces the current selection in edit controls and documents. If there is no selection it says so.") script_reportCurrentSelection.category=SCRCAT_SYSTEMCARET diff --git a/source/speech.py b/source/speech.py index 856e21439bb..87a5312b2e2 100755 --- a/source/speech.py +++ b/source/speech.py @@ -421,8 +421,7 @@ def speakObject(obj,reason=controlTypes.REASON_QUERY,index=None): info=obj.makeTextInfo(textInfos.POSITION_SELECTION) if not info.isCollapsed: # if there is selected text, then there is a value and we do not report placeholder - # Translators: This is spoken to indicate what has been selected. for example 'selected hello world' - speakSelectionMessage(_("selected %s"),info.text) + speakSelectedText(info.text) else: info.expand(textInfos.UNIT_LINE) _speakPlaceholderIfEmpty(info, obj, reason) @@ -587,6 +586,13 @@ def speak(speechSequence,symbolLevel=None): speechSequence[index]+=CHUNK_SEPARATOR getSynth().speak(speechSequence) +def speakSelectedText(text): + """ Helper method to speak the provided text with the word "selected" appended. + Implemented using L{speakSelectionMessage}, which allows for speaking text with an arbitrary attached message. + """ + # Translators: This is spoken to indicate what has been selected. for example 'hello world selected' + speakSelectionMessage(_("%s selected"),text) + def speakSelectionMessage(message,text): if len(text) < 512: speakMessage(message % text) @@ -644,14 +650,12 @@ def speakSelectionChange(oldInfo,newInfo,speakSelected=True,speakUnselected=True for text in selectedTextList: if len(text)==1: text=characterProcessing.processSpeechSymbol(locale,text) - # Translators: This is spoken while the user is in the process of selecting something, For example: "hello selected" - speakSelectionMessage(_("%s selected"),text) + speakSelectedText(text) elif len(selectedTextList)>0: text=newInfo.text if len(text)==1: text=characterProcessing.processSpeechSymbol(locale,text) - # Translators: This is spoken to indicate what has been selected. for example 'selected hello world' - speakSelectionMessage(_("selected %s"),text) + speakSelectedText(text) if speakUnselected: if not generalize: for text in unselectedTextList: