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 @@ -152,7 +152,8 @@ class Translations(POT): # {{{
13 base = os.path.dirname(dest)
14 if not os.path.exists(base):
16 - jobs.append(['msgfmt', '-o', dest, f])
17 + if self.newer(dest, f):
18 + jobs.append(['msgfmt', '-o', dest, f])
19 iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
20 iso639 = self.j(self.LP_ISO_PATH, '%s.po'%iscpo)
22 @@ -174,7 +175,6 @@ class Translations(POT): # {{{
26 - self.freeze_locales()
27 self.compile_user_manual_translations()
29 def check_iso639(self, path):
30 @@ -198,15 +198,6 @@ class Translations(POT): # {{{
34 - def freeze_locales(self):
35 - zf = self.DEST + '.zip'
36 - from calibre import CurrentDir
37 - from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
38 - with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
39 - with CurrentDir(self.DEST):
41 - shutil.rmtree(self.DEST)
45 return self.j(self.d(self.DEST), 'stats.pickle')
46 --- calibre/src/calibre/translations/dynamic.py.wiget 2013-12-06 05:13:34.000000000 +0100
47 +++ calibre/src/calibre/translations/dynamic.py 2013-12-09 09:28:32.349958101 +0100
48 @@ -5,10 +5,10 @@ Dynamic language lookup of translations
49 __license__ = 'GPL v3'
50 __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
54 from gettext import GNUTranslations
55 from calibre.utils.localization import get_lc_messages_path
56 -from zipfile import ZipFile
58 __all__ = ['translate']
60 @@ -21,15 +21,10 @@ def translate(lang, text):
62 mpath = get_lc_messages_path(lang)
64 - with ZipFile(P('localization/locales.zip',
65 - allow_user_override=False), 'r') as zf:
67 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
71 - trans = GNUTranslations(buf)
72 - _CACHE[lang] = trans
73 + p = os.path.join(mpath, 'calibre.mo')
74 + if os.path.exists(p):
75 + trans = GNUTranslations(open(p, 'rb'))
76 + _CACHE[lang] = trans
78 return getattr(__builtins__, '_', lambda x: x)(text)
79 return trans.ugettext(text)
80 --- calibre/src/calibre/utils/localization.py.wiget 2013-12-06 05:13:34.000000000 +0100
81 +++ calibre/src/calibre/utils/localization.py 2013-12-09 09:31:05.694326467 +0100
82 @@ -74,20 +74,20 @@ def get_lang():
86 +def messages_path(lang):
87 + return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
89 def get_lc_messages_path(lang):
92 - if lang in available_translations():
95 - xlang = lang.split('_')[0].lower()
96 - if xlang in available_translations():
101 - return os.path.exists(P('localization/locales.zip',
102 - allow_user_override=False))
103 + if lang in available_translations():
106 + xlang = lang.split('_')[0]
107 + if xlang in available_translations():
109 + if hlang is not None:
110 + return messages_path(hlang)
118 def get_all_translators():
119 - from zipfile import ZipFile
120 - with ZipFile(P('localization/locales.zip', allow_user_override=False), 'r') as zf:
121 - for lang in available_translations():
122 - mpath = get_lc_messages_path(lang)
123 - if mpath is not None:
124 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
125 - yield lang, GNUTranslations(buf)
126 + for lang in available_translations():
127 + mpath = get_lc_messages_path(lang)
128 + if mpath is not None:
130 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
131 + yield lang, GNUTranslations(buf)
136 u'abday': (u'Sun', u'Mon', u'Tue', u'Wed', u'Thu', u'Fri', u'Sat'),
137 @@ -145,21 +145,20 @@
138 buf = cStringIO.StringIO(buf.getvalue())
140 if mpath is not None:
141 - from zipfile import ZipFile
142 - with ZipFile(P('localization/locales.zip',
143 - allow_user_override=False), 'r') as zf:
145 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
148 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
150 + pass # No translations for this lang
153 - isof = mpath + '/iso639.mo'
155 - iso639 = cStringIO.StringIO(zf.read(isof))
156 + iso639 = open(os.path.join(mpath, 'calibre_iso639.mo'), 'rb')
158 pass # No iso639 translations for this lang
161 - lcdata = cPickle.loads(zf.read(mpath + '/lcdata.pickle'))
162 + lcdata = cPickle.loads(open(os.path.join(mpath, 'calibre_lcdata.pickle')))