예제 #1
0
	def __init__(self):
		"""Initializes the global plugin object."""
		super(globalPluginHandler.GlobalPlugin, self).__init__()
		global _nvdaSpeakText, _nvdaGetSpeechTextForProperties, _nvdaSpeak, _gpObject
		
		# if on a secure Desktop, disable the Add-on
		if globalVars.appArgs.secure: return
		_gpObject = self
		try:
			self.language = config.conf["general"]["language"]
		except:
			self.language = None
			pass
		if self.language is None or self.language == 'Windows':
			try:
				self.language = languageHandler.getWindowsLanguage()[:2]
			except:
				self.language = 'en'
				
		logHandler.log.info("Translate module initialized, translating to %s" %(self.language))
		_nvdaSpeak = speech.speak
		_nvdaGetSpeechTextForProperties = speech.getSpeechTextForProperties
		speech.speak = speak
		speech.getSpeechTextForProperties = getSpeechTextForProperties
		self.loadLocalCache()
예제 #2
0
    def __init__(self):
        """Initializes the global plugin object."""
        super(globalPluginHandler.GlobalPlugin, self).__init__()
        global _nvdaGetPropertiesSpeech, _nvdaSpeak, _gpObject

        # if on a secure Desktop, disable the Add-on
        if globalVars.appArgs.secure: return
        _gpObject = self
        try:
            self.language = config.conf["general"]["language"]
        except:
            self.language = None
            pass
        if self.language is None or self.language == 'Windows':
            try:
                self.language = languageHandler.getWindowsLanguage()[:2]
            except:
                self.language = 'en'
        self.updater = updater.ExtensionUpdater()
        self.updater.start()
        self.inTimer = False
        self.hasBeenUpdated = False
        wx.CallLater(1000, self.onTimer)
        import addonHandler
        version = None
        for addon in addonHandler.getAvailableAddons():
            if addon.name == "translate":
                version = addon.version
        if version is None:
            version = 'unknown'
        logHandler.log.info("Translate (%s) initialized, translating to %s" %
                            (version, self.language))

        _nvdaSpeak = speech._manager.speak
        _nvdaGetPropertiesSpeech = speech.getPropertiesSpeech
        speech._manager.speak = speak
        speech.getPropertiesSpeech = _nvdaGetPropertiesSpeech
        self.loadLocalCache()
예제 #3
0
파일: oneCore.py 프로젝트: zstanecic/nvda
    def _getDefaultVoice(self, pickAny: bool = True) -> str:
        """
		Finds the best available voice that can be used as a default.
		It first tries finding a voice with the same language as the user's configured NVDA language
		else one that matches the system language.
		else any voice if pickAny is True.
		Uses the Windows locale (eg en_AU) to provide country information for the voice where possible.
		@returns: the ID of the voice, suitable for passing to self.voice for setting.
		"""
        voices = self.availableVoices
        fullWindowsLanguage = languageHandler.getWindowsLanguage()
        baseWindowsLanguage = fullWindowsLanguage.split('_')[0]
        NVDALanguage = languageHandler.getLanguage()
        if NVDALanguage.startswith(baseWindowsLanguage):
            # add country information if it matches
            NVDALanguage = fullWindowsLanguage
        # Try matching to the NVDA language
        for voice in voices.values():
            if voice.language.startswith(NVDALanguage):
                return voice.id
        # Try matching to the system language and country
        if fullWindowsLanguage != NVDALanguage:
            for voice in voices.values():
                if voice.language == fullWindowsLanguage:
                    return voice.id
        # Try matching to the system language
        if baseWindowsLanguage not in {fullWindowsLanguage, NVDALanguage}:
            for voice in voices.values():
                if voice.language.startswith(baseWindowsLanguage):
                    return voice.id
        if pickAny:
            for voice in voices.values():
                return voice.id
            raise VoiceUnsupportedError("No voices available")
        raise VoiceUnsupportedError(
            "No voices available that match the user language")
예제 #4
0
    def _getDefaultVoice(self):
        """
		Finds the best available voice that can be used as a default.
		It first tries finding a voice with the same language and country as the user's configured Windows language (E.g. en_AU), 
		else one that matches just the language (E.g. en), 
		else simply the first available.
		@returns: the ID of the voice, suitable for passing to self.voice for setting.
		@rtype: string
		"""
        voices = self.availableVoices
        # Try matching to NVDA language
        fullLanguage = languageHandler.getWindowsLanguage()
        for voice in voices.values():
            if voice.language == fullLanguage:
                return voice.id
        baseLanguage = fullLanguage.split('_')[0]
        if baseLanguage != fullLanguage:
            for voice in voices.values():
                if voice.language.startswith(baseLanguage):
                    return voice.id
        # Just use the first available
        for voice in voices.values():
            return voice.id
        raise RuntimeError("No voices available")
예제 #5
0
파일: oneCore.py 프로젝트: ehollig/nvda
	def _getDefaultVoice(self):
		"""
		Finds the best available voice that can be used as a default.
		It first tries finding a voice with the same language and country as the user's configured Windows language (E.g. en_AU), 
		else one that matches just the language (E.g. en), 
		else simply the first available.
		@returns: the ID of the voice, suitable for passing to self.voice for setting.
		@rtype: string
		"""
		voices = self.availableVoices
		# Try matching to NVDA language
		fullLanguage=languageHandler.getWindowsLanguage()
		for voice in voices.itervalues():
			if voice.language==fullLanguage:
				return voice.id
		baseLanguage=fullLanguage.split('_')[0]
		if baseLanguage!=fullLanguage:
			for voice in voices.itervalues():
				if voice.language.startswith(baseLanguage):
					return voice.id
		# Just use the first available
		for voice in voices.itervalues():
			return voice.id
		raise RuntimeError("No voices available")