Exemple #1
0
	def getFormatFieldSpeech(
			self,
			attrs: textInfos.Field,
			attrsCache: Optional[textInfos.Field] = None,
			formatConfig: Optional[Dict[str, bool]] = None,
			reason: Optional[OutputReason] = None,
			unit: Optional[str] = None,
			extraDetail: bool = False,
			initialFormat: bool = False
	) -> SpeechSequence:
		out: SpeechSequence = []
		comment = attrs.get("kindle-user-note")
		if comment:
			# For now, we report this the same way we do comments.
			attrs["comment"] = comment
		highlight = attrs.get("kindle-highlight")
		oldHighlight = attrsCache.get("kindle-highlight") if attrsCache is not None else None
		if oldHighlight != highlight:
			translation = (
				# Translators: Reported when text is highlighted.
				_("highlight") if highlight else
				# Translators: Reported when text is not highlighted.
				_("no highlight")
			)
			out.append(translation)
		popular = attrs.get("kindle-popular-highlight-count")
		oldPopular = attrsCache.get("kindle-popular-highlight-count") if attrsCache is not None else None
		if oldPopular != popular:
			translation = (
				# Translators: Reported in Kindle when text has been identified as a popular highlight;
				# i.e. it has been highlighted by several people.
				# %s is replaced with the number of people who have highlighted this text.
				_("%s highlighted") % popular if popular else
				# Translators: Reported when moving out of a popular highlight.
				_("out of popular highlight")
			)
			out.append(translation)

		superSpeech = super(BookPageViewTextInfo, self).getFormatFieldSpeech(
			attrs,
			attrsCache=attrsCache,
			formatConfig=formatConfig,
			reason=reason,
			unit=unit,
			extraDetail=extraDetail,
			initialFormat=initialFormat
		)
		out.extend(superSpeech)
		textInfos._logBadSequenceTypes(out)
		return out
 def getFormatFieldSpeech(
     self,
     attrs: textInfos.Field,
     attrsCache: Optional[textInfos.Field] = None,
     formatConfig: Optional[Dict[str, bool]] = None,
     reason: Optional[OutputReason] = None,
     unit: Optional[str] = None,
     extraDetail: bool = False,
     initialFormat: bool = False,
 ) -> SpeechSequence:
     sequence = self.innerTextInfo.getFormatFieldSpeech(
         attrs,
         attrsCache=attrsCache,
         formatConfig=formatConfig,
         reason=reason,
         unit=unit,
         extraDetail=extraDetail,
         initialFormat=initialFormat)
     textInfos._logBadSequenceTypes(sequence)
     return sequence