Skip to content

Commit

Permalink
Fix plugin failing to initialize when NVDA was set to language for wh…
Browse files Browse the repository at this point in the history
…ich there is no Tesseract data
  • Loading branch information
lukaszgo1 committed Jul 20, 2021
1 parent 3fbe82e commit eea26ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions addon/globalPlugins/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LanguageInfo:
"""Provides information about a single language supported by Tesseract."""

# Tesseract identifies languages using their ISO 639-2 language codes
# whereas NVDA locales are identifed by ISO 639-1 codes.
# whereas NVDA locales are identified by ISO 639-1 codes.
# Below dictionaries provide mapping from one representation to the other.
NVDALocalesToTesseractLangs = {
"bg": "bul",
Expand Down Expand Up @@ -126,11 +126,12 @@ def fromFallbackLanguage(cls):
@classmethod
def fromCurrentNVDALanguage(cls):
currentNVDALang = languageHandler.getLanguage()
for possibleLocaleName in (currentNVDALang, currentNVDALang.split("_")[0], cls.FALLBACK_LANGUAGE):
for possibleLocaleName in (currentNVDALang, currentNVDALang.split("_")[0]):
try:
return cls(NVDALocaleName=possibleLocaleName)
except KeyError:
continue
return cls.fromFallbackLanguage()

@property
def localizedName(self):
Expand Down

0 comments on commit eea26ec

Please sign in to comment.