Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
- Fixes cache handling when translation fails
- Fixes downloads links
- bumped version to 2020.06
  • Loading branch information
Yannick Plassiard committed May 25, 2020
1 parent 195eb2f commit 7f9def2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
@@ -1,8 +1,8 @@
# nvda-translate
Make NVDA translate any spoken text to the desired language.
## Download
- Stable: [translate-2019.09.3](http://www.mtyp.fr/nvda/translate-2019.09.3.nvda-addon).
- Stable (NVDA 2019.3+): [translate-2020.01](http://www.mtyp.fr/nvda/translate-2020.05.nvda-addon).
- Stable: [translate-2019.09.3](http://www.mtyp.fr/nvda/translate/translate-2019.09.3.nvda-addon).
- Stable (NVDA 2019.3+): [translate-2020.06](http://www.mtyp.fr/nvda/translate/translate-2020.06.nvda-addon).

## Installation

Expand Down
8 changes: 4 additions & 4 deletions addon/globalPlugins/translate/__init__.py
Expand Up @@ -66,17 +66,17 @@ def translate(text):
if appTable is None:
_translationCache[appName] = {}
translated = _translationCache[appName].get(text, None)
if translated is not None:
if translated is not None and translated != text:
return translated
try:
prepared = text.encode('utf8', ':/')
translated = mtranslate.translate(prepared, _gpObject.language)
except Exception as e:
_translationCache[appName][text] = text
return text
if translated is None or len(translated) == 0:
translated = text
_translationCache[appName][text] = translated
else:
_translationCache[appName][text] = translated
return translated


Expand All @@ -98,7 +98,7 @@ def speak(speechSequence: SpeechSequence,
else:
newSpeechSequence.append(val)
_nvdaSpeak(speechSequence=newSpeechSequence, priority=priority)
_lastTranslatedText = " ".join(x if isinstance(x, str) else "" for x in newSpeechSequence)
_lastTranslatedText = " ".join(x if isinstance(x, str) else "" for x in newSpeechSequence)

#
## This is overloaded as well because the generated text may contain already translated text by
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Expand Up @@ -20,7 +20,7 @@
"addon_description" : _("""Uses the Google Translate API to translate each spoken text to the desired language, on the fly.
This add-on requires an internet connection."""),
# version
"addon_version" : "2020.05",
"addon_version" : "2020.06",
# Author(s)
"addon_author" : u"Yannick PLASSIARD <podcastcecitek@gmail.com>",
# URL for the add-on documentation support
Expand Down

1 comment on commit 7f9def2

@johnykulik4025
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this link to download not working

Please sign in to comment.