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 logging
|
||||||
import nw
|
import nw
|
||||||
|
|
||||||
|
from nw.constants import isoLanguage
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class NWSpellCheck():
|
class NWSpellCheck():
|
||||||
@@ -54,6 +56,17 @@ class NWSpellCheck():
|
|||||||
def listDictionaries(self):
|
def listDictionaries(self):
|
||||||
return []
|
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
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import enchant
|
|||||||
import nw
|
import nw
|
||||||
|
|
||||||
from nw.tools.spellcheck import NWSpellCheck
|
from nw.tools.spellcheck import NWSpellCheck
|
||||||
from nw.constants import isoLanguage
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -58,15 +57,7 @@ class NWSpellEnchant(NWSpellCheck):
|
|||||||
def listDictionaries(self):
|
def listDictionaries(self):
|
||||||
retList = []
|
retList = []
|
||||||
for spTag, spProvider in enchant.list_dicts():
|
for spTag, spProvider in enchant.list_dicts():
|
||||||
spList = []
|
spName = "%s [%s]" % (self.expandLanguage(spTag), spProvider.name)
|
||||||
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)
|
|
||||||
retList.append((spTag, spName))
|
retList.append((spTag, spName))
|
||||||
return retList
|
return retList
|
||||||
|
|
||||||
|
|||||||
+2
-12
@@ -19,7 +19,6 @@ from difflib import get_close_matches
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
from nw.tools.spellcheck import NWSpellCheck
|
from nw.tools.spellcheck import NWSpellCheck
|
||||||
from nw.constants import isoLanguage
|
|
||||||
|
|
||||||
class NWSpellSimple(NWSpellCheck):
|
class NWSpellSimple(NWSpellCheck):
|
||||||
|
|
||||||
@@ -105,17 +104,8 @@ class NWSpellSimple(NWSpellCheck):
|
|||||||
if theBits[1] != ".dict":
|
if theBits[1] != ".dict":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
spTag = theBits[0]
|
spName = "%s [nternal]" % self.expandLanguage(theBits[0])
|
||||||
spList = []
|
retList.append((theBits[0], spName))
|
||||||
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))
|
|
||||||
|
|
||||||
return retList
|
return retList
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user