Beispiel #1
0
 def getUserComplexSymbols(self):
     from languageHandler import curLang
     lang = curLang.split("-")[0]
     conf = self.addonConfig
     if SCT_CategoriesAndSymbols in conf\
      and lang in conf[SCT_CategoriesAndSymbols]:
         return conf[SCT_CategoriesAndSymbols][lang].copy()
     return {}
Beispiel #2
0
 def getRedefinedKeyLabels(self):
     from languageHandler import curLang
     lang = curLang.split("-")[0]
     conf = self.addonConfig
     if SCT_RedefinedKeyLabels in conf and lang in conf[
             SCT_RedefinedKeyLabels]:
         labels = conf[SCT_RedefinedKeyLabels][lang].copy()
         if len(labels):
             return labels
     return {}
 def onSeeHistory(self, evt):
     addon = addonHandler.getCodeAddon()
     from languageHandler import curLang
     theFile = os.path.join(addon.path, "doc", curLang, "changes.html")
     if not os.path.exists(theFile):
         lang = curLang.split("_")[0]
         theFile = os.path.join(addon.path, "doc", lang, "changes.html")
         if not os.path.exists(theFile):
             lang = "en"
             theFile = os.path.join(addon.path, "doc", lang, "changes.html")
     os.startfile(theFile)
Beispiel #4
0
 def saveRedefinedKeyLabels(self, keyLabels):
     from languageHandler import curLang
     lang = curLang.split("-")[0]
     conf = self.addonConfig
     if SCT_RedefinedKeyNames not in conf:
         conf[SCT_RedefinedKeyLabels] = {}
     elif lang in conf[SCT_RedefinedKeyLabels]:
         del conf[SCT_RedefinedKeyLabels][lang]
     conf[SCT_RedefinedKeyLabels][lang] = {}
     for keyName in keyLabels:
         conf[SCT_RedefinedKeyLabels][lang][keyName] = keyLabels[keyName]
Beispiel #5
0
 def saveUserComplexSymbols(self, userComplexSymbols):
     from languageHandler import curLang
     lang = curLang.split("-")[0]
     conf = self.addonConfig
     if SCT_CategoriesAndSymbols not in conf:
         conf[SCT_CategoriesAndSymbols] = {}
     conf[SCT_CategoriesAndSymbols][lang] = {}
     for sect in userComplexSymbols:
         if sect not in conf[SCT_CategoriesAndSymbols][lang]:
             conf[SCT_CategoriesAndSymbols][lang][sect] = {}
         for symbol in userComplexSymbols[sect]:
             conf[SCT_CategoriesAndSymbols ][lang][sect][symbol] =\
              userComplexSymbols[sect][symbol]
def getNewSymbolsFile(folder):
	lang = curLang
	if "_" in curLang:
		lang = curLang.split("_")[0]
	newSymbolsFileName = "symbols-" + lang + ".dic"
	newSymbolsFileList = os.listdir(folder)
	if newSymbolsFileName in newSymbolsFileList:
		if sys.version.startswith("3"):
			# for python 3
			return newSymbolsFileName
		else:
			# for python 2
			return newSymbolsFileName.encode("utf-8")
	return None
    def getLocaleSettingsIniFilePath(self):
        settingsIniFileName = "settings.ini"
        lang = curLang
        settingsIniFilePath = os.path.join(self.addonDir, "locale", curLang,
                                           settingsIniFileName)
        if not os.path.exists(settingsIniFilePath):
            lang = curLang.split("_")[0]
            settingsIniFilePath = os.path.join(self.addonDir, "locale", lang,
                                               settingsIniFileName)
            if not os.path.exists(settingsIniFilePath):
                log.warning("No settingsIniFile %s for %s" %
                            (settingsIniFilePath, curLang))  # noqa:E501
                settingsIniFilePath = None

        return settingsIniFilePath
Beispiel #8
0
	def script_displayAudacityGuide (self, gesture):
		stopTaskTimer()
		from languageHandler import curLang
		lang = curLang
		docPath = os.path.join(_addonDir , "doc")
		guide = "audacityGuide.html"
		defaultPath = os.path.join(docPath, "en", guide)
		localPath = os.path.join(docPath, lang, guide)
		if os.path.exists(localPath):
			self.startFile(localPath)
			return
		lang = curLang.split("_")[0]
		localPath = os.path.join(docPath, lang, guide)
		if os.path.exists(localPath):
			self.startFile(localPath)
		elif os.path.exists(defaultPath):
			self.startFile(defaultPath)
		else:
			ui.message(_("Error: audacity guide is not found"))
Beispiel #9
0
	def script_displayAddonUserManual (self, gesture):
		stopTaskTimer()
		from languageHandler import curLang
		lang = curLang
		docPath = os.path.join(_addonDir , "doc")
		manual =  _curAddon.manifest["docFileName"]
		defaultPath = os.path.join(docPath, "en", manual)
		localePath = os.path.join(docPath, lang, manual)
		if os.path.exists(localePath):
			self.startFile(localePath)
			return
		lang = curLang.split("_")[0]
		localePath = os.path.join(docPath, lang, manual)
		if os.path.exists(localePath):
			self.startFile(localePath)
		elif os.path.exists(defaultPath):
			self.startFile(defaultPath)
		else:
			ui.message(_("Error: Add-on user manual is not found"))
Beispiel #10
0
 def getreleaseNoteURL(self):
     baseURL = "https://rawgit.com/paulber007/AllMyNVDAAddons/master"
     basereleaseNoteURL = "{baseURL}/{addonName}/{releaseNotes}".format(
         baseURL=baseURL,
         addonName=self.addon.manifest["name"],
         releaseNotes="releaseNotes")
     from languageHandler import curLang
     url = "{url}/{language}/changes.html".format(url=basereleaseNoteURL,
                                                  language=curLang)
     try:
         urlopen(url)
     except IOError:
         lang = curLang.split("_")[0]
         url = "{url}/{language}/changes.html".format(
             url=basereleaseNoteURL, language=lang)
         try:
             urlopen(url)
         except IOError:
             url = "{url}/{language}/changes.html".format(
                 url=basereleaseNoteURL, language="en")
     return url
Beispiel #11
0
 def getSymbolCategoriesDicPath(self):
     userFile = self.getUserSymbolCategoriesFile(curLang)
     if userFile is not None:
         return userFile
     localeList = [curLang]
     if '_' in curLang:
         localeList.append(curLang.split('_')[0])
     localeList.append("en")
     addonFolderPath = addonHandler.getCodeAddon().path
     fileName = ".".join(symbolCategoriesFile)
     for locale in localeList:
         if py3:
             # for python 3
             file = os.path.join(addonFolderPath, "locale", locale,
                                 fileName)
         else:
             # for python 2
             file = os.path.join(addonFolderPath, "locale",
                                 locale.encode("utf-8"), fileName)
         if os.path.isfile(file):
             return file
     return None