Added a function to create a readable spell language string for the status bar
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from nw.constants import isoLanguage
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class NWSpellCheck():
|
||||
@@ -54,6 +56,17 @@ class NWSpellCheck():
|
||||
def listDictionaries(self):
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def expandLanguage(spTag):
|
||||
spBits = spTag.split("_")
|
||||
if spBits[0] in isoLanguage.ISO_639_1:
|
||||
spLang = isoLanguage.ISO_639_1[spBits[0]]
|
||||
else:
|
||||
spLang = spBits[0]
|
||||
if len(spBits) > 1:
|
||||
spLang += " (%s)" % spBits[1]
|
||||
return spLang
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
@@ -15,7 +15,6 @@ import enchant
|
||||
import nw
|
||||
|
||||
from nw.tools.spellcheck import NWSpellCheck
|
||||
from nw.constants import isoLanguage
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -58,15 +57,7 @@ class NWSpellEnchant(NWSpellCheck):
|
||||
def listDictionaries(self):
|
||||
retList = []
|
||||
for spTag, spProvider in enchant.list_dicts():
|
||||
spList = []
|
||||
if spTag[:2] in isoLanguage.ISO_639_1:
|
||||
spList.append(isoLanguage.ISO_639_1[spTag[:2]])
|
||||
else:
|
||||
spList.append(spTag[:2])
|
||||
if len(spTag) > 3:
|
||||
spList.append("(%s)" % spTag[3:])
|
||||
spList.append("[%s]" % spProvider.name)
|
||||
spName = " ".join(spList)
|
||||
spName = "%s [%s]" % (self.expandLanguage(spTag), spProvider.name)
|
||||
retList.append((spTag, spName))
|
||||
return retList
|
||||
|
||||
|
||||
+2
-12
@@ -19,7 +19,6 @@ from difflib import get_close_matches
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from nw.tools.spellcheck import NWSpellCheck
|
||||
from nw.constants import isoLanguage
|
||||
|
||||
class NWSpellSimple(NWSpellCheck):
|
||||
|
||||
@@ -105,17 +104,8 @@ class NWSpellSimple(NWSpellCheck):
|
||||
if theBits[1] != ".dict":
|
||||
continue
|
||||
|
||||
spTag = theBits[0]
|
||||
spList = []
|
||||
if spTag[:2] in isoLanguage.ISO_639_1:
|
||||
spList.append(isoLanguage.ISO_639_1[spTag[:2]])
|
||||
else:
|
||||
spList.append(spTag[:2])
|
||||
if len(spTag) > 3:
|
||||
spList.append("(%s)" % spTag[3:])
|
||||
spList.append("[internal]")
|
||||
spName = " ".join(spList)
|
||||
retList.append((spTag, spName))
|
||||
spName = "%s [nternal]" % self.expandLanguage(theBits[0])
|
||||
retList.append((theBits[0], spName))
|
||||
|
||||
return retList
|
||||
|
||||
|
||||
Reference in New Issue
Block a user