mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-04 20:36:25 +01:00
A spot of refactoring
This commit is contained in:
parent
a0e87cb532
commit
c088f7e818
2 changed files with 12 additions and 14 deletions
|
|
@ -9,20 +9,9 @@
|
|||
|
||||
from calibre.gui2 import gui_prefs
|
||||
from calibre.gui2.complete2 import EditWithComplete
|
||||
from calibre.utils.localization import lang_map
|
||||
from calibre.utils.localization import lang_map_for_ui
|
||||
from calibre.utils.icu import sort_key, lower
|
||||
|
||||
_lang_map = None
|
||||
|
||||
|
||||
def get_lang_map():
|
||||
global _lang_map
|
||||
if _lang_map is None:
|
||||
_lang_map = lang_map().copy()
|
||||
for x in ('zxx', 'mis', 'mul'):
|
||||
_lang_map.pop(x, None)
|
||||
return _lang_map
|
||||
|
||||
|
||||
class LanguagesEdit(EditWithComplete):
|
||||
|
||||
|
|
@ -33,7 +22,7 @@ def __init__(self, parent=None, db=None, prefs=None):
|
|||
|
||||
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
|
||||
self.setMinimumContentsLength(20)
|
||||
self._lang_map = get_lang_map()
|
||||
self._lang_map = lang_map_for_ui()
|
||||
self.names_with_commas = [x for x in self._lang_map.itervalues() if ',' in x]
|
||||
self.comma_map = {k:k.replace(',', '|') for k in self.names_with_commas}
|
||||
self.comma_rmap = {v:k for k, v in self.comma_map.iteritems()}
|
||||
|
|
@ -114,4 +103,3 @@ def validate(self):
|
|||
if code is None:
|
||||
bad.append(name)
|
||||
return bad
|
||||
|
||||
|
|
|
|||
|
|
@ -426,6 +426,16 @@ def lang_map():
|
|||
return _lang_map
|
||||
|
||||
|
||||
def lang_map_for_ui():
|
||||
ans = getattr(lang_map_for_ui, 'ans', None)
|
||||
if ans is None:
|
||||
ans = lang_map().copy()
|
||||
for x in ('zxx', 'mis', 'mul'):
|
||||
ans.pop(x, None)
|
||||
lang_map_for_ui.ans = ans
|
||||
return ans
|
||||
|
||||
|
||||
def langnames_to_langcodes(names):
|
||||
'''
|
||||
Given a list of localized language names return a mapping of the names to 3
|
||||
|
|
|
|||
Loading…
Reference in a new issue