mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Get default locale in more reliable way
This commit is contained in:
parent
0a0649a0db
commit
b3ba8e813d
|
@ -2,7 +2,7 @@
|
|||
# --!-- coding: utf8 --!--
|
||||
import re
|
||||
|
||||
from PyQt5.QtCore import QTimer, QModelIndex, Qt, QEvent, pyqtSignal, QRegExp
|
||||
from PyQt5.QtCore import QTimer, QModelIndex, Qt, QEvent, pyqtSignal, QRegExp, QLocale
|
||||
from PyQt5.QtGui import QTextBlockFormat, QTextCharFormat, QFont, QColor, QIcon, QMouseEvent, QTextCursor
|
||||
from PyQt5.QtWidgets import QWidget, QTextEdit, qApp, QAction, QMenu
|
||||
|
||||
|
@ -76,7 +76,7 @@ class textEditView(QTextEdit):
|
|||
# Spellchecking
|
||||
if enchant and self.spellcheck:
|
||||
try:
|
||||
self._dict = enchant.Dict(self.currentDict if self.currentDict else enchant.get_default_language())
|
||||
self._dict = enchant.Dict(self.currentDict if self.currentDict else self.getDefaultLocale())
|
||||
except enchant.errors.DictNotFoundError:
|
||||
self.spellcheck = False
|
||||
|
||||
|
@ -87,6 +87,15 @@ class textEditView(QTextEdit):
|
|||
self.highlighter = basicHighlighter(self)
|
||||
self.highlighter.setDefaultBlockFormat(self._defaultBlockFormat)
|
||||
|
||||
def getDefaultLocale(self):
|
||||
default_locale = enchant.get_default_language()
|
||||
if default_locale is None:
|
||||
default_locale = QLocale.system().name()
|
||||
if default_locale is None:
|
||||
default_locale = enchant.list_dicts()[0][0]
|
||||
|
||||
return default_locale
|
||||
|
||||
def setModel(self, model):
|
||||
self._model = model
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue