コード例 #1
0
 def _normalizeFormatField(self, attrs):
     try:
         attrs["language"] = languageHandler.normalizeLanguage(
             attrs["language"])
     except KeyError:
         pass
     return attrs
コード例 #2
0
	def _getLanguageFromLcid(self, lcid):
		"""
		gets a normalized locale from a lcid
		"""
		lang = locale.windows_locale[lcid]
		if lang:
			return languageHandler.normalizeLanguage(lang)
コード例 #3
0
ファイル: adobeAcrobat.py プロジェクト: bramd/nvda
	def _normalizeFormatField(self, attrs):
		try:
			attrs["language"] = languageHandler.normalizeLanguage(attrs["language"])
		except KeyError:
			pass
		try:
			attrs["_indexInParent"] = int(attrs["_indexInParent"])
		except KeyError:
			pass
		return attrs
コード例 #4
0
ファイル: adobeAcrobat.py プロジェクト: zstanecic/nvda
	def _normalizeFormatField(self, attrs):
		try:
			attrs["language"] = languageHandler.normalizeLanguage(attrs["language"])
		except KeyError:
			pass
		try:
			attrs["_indexInParent"] = int(attrs["_indexInParent"])
		except KeyError:
			pass
		fontSize = attrs.get("font-size")
		if fontSize is not None:
			# Translators: Abbreviation for points, a measurement of font size.
			attrs["font-size"] = pgettext("font size", "%s pt") % fontSize
		return attrs
コード例 #5
0
 def _normalizeFormatField(self, attrs):
     formatState = attrs.get('formatState', "0")
     formatState = int(formatState)
     if formatState & FORMATSTATE_INSERTED:
         attrs['revision-insertion'] = True
     if formatState & FORMATSTATE_DELETED:
         attrs['revision-deletion'] = True
     if formatState & FORMATSTATE_STRONG:
         attrs['strong'] = True
     if formatState & FORMATSTATE_EMPH:
         attrs['emphasised'] = True
     language = attrs.get('language')
     if language:
         attrs['language'] = languageHandler.normalizeLanguage(language)
     return attrs
コード例 #6
0
ファイル: uwpOcr.py プロジェクト: xingkong0113/nvda
def _getInitialLanguage(nvdaLang, ocrLangs):
    # Try the full language code.
    for lang in ocrLangs:
        normLang = languageHandler.normalizeLanguage(lang)
        if nvdaLang == normLang:
            return lang
    # Try the language code without country.
    nvdaLangPrimary = nvdaLang.split("_", 1)[0]
    for lang in ocrLangs:
        # Don't need to normalize here because the primary code is
        # the same when normalized.
        if lang.startswith(nvdaLangPrimary):
            return lang
    # Fall back to the first OCR language.
    if len(ocrLangs) >= 1:
        return ocrLangs[0]
    raise LookupError("No UWP OCR languages installed")
コード例 #7
0
ファイル: MSHTML.py プロジェクト: eklipse2009/nvda
	def _normalizeFormatField(self, attrs):
		formatState=attrs.get('formatState',"0")
		formatState=int(formatState)
		if formatState&FORMATSTATE_INSERTED:
			attrs['revision-insertion']=True
		if formatState&FORMATSTATE_DELETED:
			attrs['revision-deletion']=True
		if formatState&FORMATSTATE_MARKED:
			attrs['marked']=True
		if formatState&FORMATSTATE_STRONG:
			attrs['strong']=True
		if formatState&FORMATSTATE_EMPH:
			attrs['emphasised']=True
		language=attrs.get('language')
		if language:
			attrs['language']=languageHandler.normalizeLanguage(language)
		return attrs
コード例 #8
0
ファイル: uwpOcr.py プロジェクト: BabbageCom/nvda
def _getInitialLanguage(nvdaLang, ocrLangs):
	# Try the full language code.
	for lang in ocrLangs:
		normLang = languageHandler.normalizeLanguage(lang)
		if nvdaLang == normLang:
			return lang
	# Try the language code without country.
	nvdaLangPrimary = nvdaLang.split("_", 1)[0]
	for lang in ocrLangs:
		# Don't need to normalize here because the primary code is
		# the same when normalized.
		if lang.startswith(nvdaLangPrimary):
			return lang
	# Fall back to the first OCR language.
	if len(ocrLangs) >= 1:
		return ocrLangs[0]
	raise LookupError("No UWP OCR languages installed")
コード例 #9
0
ファイル: MSHTML.py プロジェクト: zstanecic/nvda
 def _normalizeFormatField(self, attrs):
     formatState = attrs.get('formatState', "0")
     formatState = int(formatState)
     if formatState & FORMATSTATE_INSERTED:
         attrs['revision-insertion'] = True
     if formatState & FORMATSTATE_DELETED:
         attrs['revision-deletion'] = True
     if formatState & FORMATSTATE_STRONG:
         attrs['strong'] = True
     if formatState & FORMATSTATE_EMPH:
         attrs['emphasised'] = True
     language = attrs.get('language')
     if language:
         attrs['language'] = languageHandler.normalizeLanguage(language)
     textPosition = attrs.get('textPosition')
     textPosition = self._getTextPositionAttribute(attrs)
     attrs['text-position'] = textPosition
     fontSize = attrs.get("font-size")
     if fontSize is not None:
         attrs["font-size"] = FontSize.translateFromAttribute(fontSize)
     return attrs
コード例 #10
0
ファイル: MSHTML.py プロジェクト: sonar-gnu-linux/nvda
 def _normalizeFormatField(self, attrs):
     language = attrs.get("language")
     if language:
         attrs["language"] = languageHandler.normalizeLanguage(language)
     return attrs
コード例 #11
0
	def test_meta_languages_no_normalization(self):
		"""Ensures that for meta languages such as x-western `None` is returned."""
		self.assertIsNone(languageHandler.normalizeLanguage("x-western"))
コード例 #12
0
	def test_underscore_used_as_separator_after_normalization(self):
		"""Ensures that underscore is used to separate country info from language.
		Also implicitly test the fact that country code is converted to upper case."""
		self.assertEqual("pt_BR", languageHandler.normalizeLanguage("pt_BR"))
		self.assertEqual("pt_BR", languageHandler.normalizeLanguage("pt-BR"))
コード例 #13
0
	def test_normalization_no_country_info(self):
		"""Makes sure that if no country info is provided language is normalized to lower case."""
		self.assertEqual("en", languageHandler.normalizeLanguage("en"))
		self.assertEqual("en", languageHandler.normalizeLanguage("EN"))
		self.assertEqual("kmr", languageHandler.normalizeLanguage("kmr"))
コード例 #14
0
ファイル: manager.py プロジェクト: steverep/nvda
    def _processSpeechSequence(self, inSeq: SpeechSequence):
        paramTracker = ParamChangeTracker()
        enteredTriggers = []
        outSeqs = []
        paramsToReplay = []
        currentSynth = getSynth()

        outSeq = []
        for command in inSeq:
            if isinstance(
                    command,
                    LangChangeCommand) and currentSynth.name == 'oneCore':
                langCode = command.lang.split('_')[0]
                langSupported = False
                currentSynthLanguages = currentSynth.availableLanguages
                for lang in currentSynthLanguages:
                    if lang and normalizeLanguage(lang).split(
                            '_')[0] == langCode:
                        langSupported = True
                if not langSupported:
                    log.warning(
                        f"Language {command.lang} not supported by {currentSynth.name} ({currentSynthLanguages})"
                    )
            if isinstance(command, BaseCallbackCommand):
                # When the synth reaches this point, we want to call the callback.
                speechIndex = next(self._indexCounter)
                outSeq.append(IndexCommand(speechIndex))
                self._indexesToCallbacks[speechIndex] = command
                # We split at indexes so we easily know what has completed speaking.
                outSeqs.append(paramsToReplay + outSeq)
                paramsToReplay.clear()
                outSeq.clear()
                continue
            if isinstance(command, ConfigProfileTriggerCommand):
                if not command.trigger.hasProfile:
                    # Ignore triggers that have no associated profile.
                    continue
                if command.enter and command.trigger in enteredTriggers:
                    log.debugWarning(
                        "Request to enter trigger which has already been entered: %r"
                        % command.trigger.spec)
                    continue
                if not command.enter and command.trigger not in enteredTriggers:
                    log.debugWarning(
                        "Request to exit trigger which wasn't entered: %r" %
                        command.trigger.spec)
                    continue
                self._ensureEndUtterance(outSeq, outSeqs, paramsToReplay,
                                         paramTracker)
                outSeqs.append([command])
                if command.enter:
                    enteredTriggers.append(command.trigger)
                else:
                    enteredTriggers.remove(command.trigger)
                continue
            if isinstance(command, EndUtteranceCommand):
                self._ensureEndUtterance(outSeq, outSeqs, paramsToReplay,
                                         paramTracker)
                continue
            if isinstance(command, SynthParamCommand):
                paramTracker.update(command)
            outSeq.append(command)
        # Add the last sequence and make sure the sequence ends the utterance.
        self._ensureEndUtterance(outSeq, outSeqs, paramsToReplay, paramTracker)
        # Exit any profile triggers the caller didn't exit.
        for trigger in reversed(enteredTriggers):
            command = ConfigProfileTriggerCommand(trigger, False)
            outSeqs.append([command])
        return outSeqs
コード例 #15
0
 def _normalizeFormatField(self, attrs):
     language = attrs.get('language')
     if language:
         attrs['language'] = languageHandler.normalizeLanguage(language)
     return attrs