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 @@ -21,15 +21,10 @@ def translate(lang, text):
40 mpath = get_lc_messages_path(lang)
42 - with ZipFile(P('localization/locales.zip',
43 - allow_user_override=False), 'r') as zf:
45 - buf = io.BytesIO(zf.read(mpath + '/messages.mo'))
49 - trans = GNUTranslations(buf)
50 - _CACHE[lang] = trans
51 + p = os.path.join(mpath, 'calibre.mo')
52 + if os.path.exists(p):
53 + trans = GNUTranslations(open(p, 'rb'))
54 + _CACHE[lang] = trans
56 return getattr(__builtins__, '_', lambda x: x)(text)
57 return trans.ugettext(text)
58 --- calibre/src/calibre/utils/localization.py.wiget 2013-12-06 05:13:34.000000000 +0100
59 +++ calibre/src/calibre/utils/localization.py 2013-12-09 09:31:05.694326467 +0100
60 @@ -74,21 +74,20 @@ def get_lang():
61 return get_lang()[:2].lower() in {'he', 'ar'}
64 +def messages_path(lang):
65 + return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
67 def get_lc_messages_path(lang):
70 - if lang in available_translations():
73 - xlang = lang.split('_')[0].lower()
74 - if xlang in available_translations():
80 - return os.path.exists(P('localization/locales.zip',
81 - allow_user_override=False))
82 + if lang in available_translations():
85 + xlang = lang.split('_')[0]
86 + if xlang in available_translations():
88 + if hlang is not None:
89 + return messages_path(hlang)
97 def get_all_translators():
98 - from zipfile import ZipFile
99 - with ZipFile(P('localization/locales.zip', allow_user_override=False), 'r') as zf:
100 - for lang in available_translations():
101 - mpath = get_lc_messages_path(lang)
102 - if mpath is not None:
103 - buf = io.BytesIO(zf.read(mpath + '/messages.mo'))
104 - yield lang, GNUTranslations(buf)
105 + for lang in available_translations():
106 + mpath = get_lc_messages_path(lang)
107 + if mpath is not None:
109 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
110 + yield lang, GNUTranslations(buf)
115 u'abday': (u'Sun', u'Mon', u'Tue', u'Wed', u'Thu', u'Fri', u'Sat'),
116 @@ -134,20 +134,11 @@
119 def get_single_translator(mpath, which='messages'):
120 - from zipfile import ZipFile
121 - with ZipFile(P('localization/locales.zip', allow_user_override=False), 'r') as zf:
122 - path = '{}/{}.mo'.format(mpath, which)
123 - data = zf.read(path)
124 - buf = io.BytesIO(data)
126 + buf = open(os.path.join(mpath, '/%s.mo' % which), 'rb')
127 return GNUTranslations(buf)
128 except Exception as e:
130 - traceback.print_exc()
132 - sig = hashlib.sha1(data).hexdigest()
133 - raise ValueError('Failed to load translations for: {} (size: {} and signature: {}) with error: {}'.format(
134 - path, len(data), sig, e))
135 + pass # No translations for this lang
138 def get_iso639_translator(lang):
139 @@ -145,22 +145,21 @@
140 buf = io.BytesIO(buf.getvalue())
142 if mpath is not None:
143 - from zipfile import ZipFile
144 - with ZipFile(P('localization/locales.zip',
145 - allow_user_override=False), 'r') as zf:
147 - buf = io.BytesIO(zf.read(mpath + '/messages.mo'))
150 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
152 + pass # No translations for this lang
155 - isof = mpath + '/iso639.mo'
157 - iso639 = io.BytesIO(zf.read(isof))
158 + iso639 = open(os.path.join(mpath, 'calibre_iso639.mo'), 'rb')
160 pass # No iso639 translations for this lang
162 from calibre.utils.serialize import msgpack_loads
164 - lcdata = msgpack_loads(zf.read(mpath + '/lcdata.calibre_msgpack'))
165 + lcdata = msgpack_loads(open(os.path.join(mpath, '/lcdata.calibre_msgpack')))