mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
fix lang initialization
This commit is contained in:
parent
454f216ac9
commit
70f901c9b4
1 changed files with 10 additions and 14 deletions
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import os, sys, cPickle, locale, types, shutil, time
|
import os, sys, cPickle, locale, types, shutil, time, re
|
||||||
from anki.utils import genID
|
from anki.utils import genID
|
||||||
|
|
||||||
# compatability
|
# compatability
|
||||||
|
@ -135,6 +135,13 @@ class Config(dict):
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
os.rename(tmpname, path)
|
os.rename(tmpname, path)
|
||||||
|
|
||||||
|
def fixLang(self, lang):
|
||||||
|
if lang and lang not in ("pt_BR", "zh_CN", "zh_TW"):
|
||||||
|
lang = re.sub("(.*)_.*", "\\1", lang)
|
||||||
|
if not lang:
|
||||||
|
lang = "en"
|
||||||
|
return lang
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
base = self.configPath
|
base = self.configPath
|
||||||
db = self.getDbPath()
|
db = self.getDbPath()
|
||||||
|
@ -151,16 +158,5 @@ class Config(dict):
|
||||||
s = self['recentDeckPaths'][n]
|
s = self['recentDeckPaths'][n]
|
||||||
if not isinstance(s, types.UnicodeType):
|
if not isinstance(s, types.UnicodeType):
|
||||||
self['recentDeckPaths'][n] = unicode(s, sys.getfilesystemencoding())
|
self['recentDeckPaths'][n] = unicode(s, sys.getfilesystemencoding())
|
||||||
# fix old locale settings
|
# fix locale settings
|
||||||
if self["interfaceLang"] == "ja":
|
self["interfaceLang"] = self.fixLang(self["interfaceLang"])
|
||||||
self["interfaceLang"]="ja_JP"
|
|
||||||
elif self["interfaceLang"] == "fr":
|
|
||||||
self["interfaceLang"]="fr_FR"
|
|
||||||
elif self["interfaceLang"] == "en":
|
|
||||||
self["interfaceLang"]="en_US"
|
|
||||||
elif self["interfaceLang"] == "de":
|
|
||||||
self["interfaceLang"]="de_DE"
|
|
||||||
elif self["interfaceLang"] == "es":
|
|
||||||
self["interfaceLang"]="es_ES"
|
|
||||||
elif not self["interfaceLang"]:
|
|
||||||
self["interfaceLang"]="en"
|
|
||||||
|
|
Loading…
Reference in a new issue