1 --- calibre/setup/translations.py.wiget 2013-12-06 05:13:34.000000000 +0100
2 +++ calibre/setup/translations.py 2013-12-09 09:28:32.349958101 +0100
3 @@ -143,7 +143,7 @@ class Translations(POT): # {{{
5 def mo_file(self, po_file):
6 locale = os.path.splitext(os.path.basename(po_file))[0]
7 - return locale, os.path.join(self.DEST, locale, 'messages.mo')
8 + return locale, os.path.join(self.DEST, locale, 'LC_MESSAGES', 'messages.mo')
11 self.iso639_errors = []
12 @@ -174,7 +175,6 @@ class Translations(POT): # {{{
14 self.compile_main_translations()
15 self.compile_content_server_translations()
16 - self.freeze_locales()
17 self.compile_user_manual_translations()
19 def compile_group(self, files, handle_stats=None, file_ok=None, action_per_file=None):
20 @@ -198,15 +198,6 @@ class Translations(POT): # {{{
24 - def freeze_locales(self):
25 - zf = self.DEST + '.zip'
26 - from calibre import CurrentDir
27 - from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
28 - with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
29 - with CurrentDir(self.DEST):
31 - shutil.rmtree(self.DEST)
35 return self.j(self.d(self.DEST), 'stats.pickle')
36 --- calibre/src/calibre/translations/dynamic.py.wiget 2013-12-06 05:13:34.000000000 +0100
37 +++ calibre/src/calibre/translations/dynamic.py 2013-12-09 09:28:32.349958101 +0100
38 @@ -5,10 +5,10 @@ Dynamic language lookup of translations
39 __license__ = 'GPL v3'
40 __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
44 from gettext import GNUTranslations
45 from calibre.utils.localization import get_lc_messages_path
46 -from zipfile import ZipFile
48 __all__ = ['translate']
50 @@ -21,15 +21,10 @@ def translate(lang, text):
52 mpath = get_lc_messages_path(lang)
54 - with ZipFile(P('localization/locales.zip',
55 - allow_user_override=False), 'r') as zf:
57 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
61 - trans = GNUTranslations(buf)
62 - _CACHE[lang] = trans
63 + p = os.path.join(mpath, 'calibre.mo')
64 + if os.path.exists(p):
65 + trans = GNUTranslations(open(p, 'rb'))
66 + _CACHE[lang] = trans
68 return getattr(__builtins__, '_', lambda x: x)(text)
69 return trans.ugettext(text)
70 --- calibre/src/calibre/utils/localization.py.wiget 2013-12-06 05:13:34.000000000 +0100
71 +++ calibre/src/calibre/utils/localization.py 2013-12-09 09:31:05.694326467 +0100
72 @@ -74,21 +74,20 @@ def get_lang():
73 return get_lang()[:2].lower() in {'he', 'ar'}
76 +def messages_path(lang):
77 + return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
79 def get_lc_messages_path(lang):
82 - if lang in available_translations():
85 - xlang = lang.split('_')[0].lower()
86 - if xlang in available_translations():
92 - return os.path.exists(P('localization/locales.zip',
93 - allow_user_override=False))
94 + if lang in available_translations():
97 + xlang = lang.split('_')[0]
98 + if xlang in available_translations():
100 + if hlang is not None:
101 + return messages_path(hlang)
109 def get_all_translators():
110 - from zipfile import ZipFile
111 - with ZipFile(P('localization/locales.zip', allow_user_override=False), 'r') as zf:
112 - for lang in available_translations():
113 - mpath = get_lc_messages_path(lang)
114 - if mpath is not None:
115 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
116 - yield lang, GNUTranslations(buf)
117 + for lang in available_translations():
118 + mpath = get_lc_messages_path(lang)
119 + if mpath is not None:
121 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
122 + yield lang, GNUTranslations(buf)
127 u'abday': (u'Sun', u'Mon', u'Tue', u'Wed', u'Thu', u'Fri', u'Sat'),
128 @@ -145,21 +145,20 @@
129 buf = cStringIO.StringIO(buf.getvalue())
131 if mpath is not None:
132 - from zipfile import ZipFile
133 - with ZipFile(P('localization/locales.zip',
134 - allow_user_override=False), 'r') as zf:
136 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
139 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
141 + pass # No translations for this lang
144 - isof = mpath + '/iso639.mo'
146 - iso639 = cStringIO.StringIO(zf.read(isof))
147 + iso639 = open(os.path.join(mpath, 'calibre_iso639.mo'), 'rb')
149 pass # No iso639 translations for this lang
152 - lcdata = cPickle.loads(zf.read(mpath + '/lcdata.pickle'))
153 + lcdata = cPickle.loads(open(os.path.join(mpath, 'calibre_lcdata.pickle')))