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,8 +152,9 @@ class Translations(POT): # {{{
13 base = os.path.dirname(dest)
14 if not os.path.exists(base):
16 - self.info('\tCompiling translations for', locale)
17 - subprocess.check_call(['msgfmt', '-o', dest, f])
18 + if self.newer(dest, f):
19 + self.info('\tCompiling translations for', locale)
20 + subprocess.check_call(['msgfmt', '-o', dest, f])
21 iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
22 iso639 = self.j(self.LP_ISO_PATH, '%s.po'%iscpo)
24 @@ -174,7 +175,6 @@ class Translations(POT): # {{{
28 - self.freeze_locales()
30 def check_iso639(self, path):
31 from calibre.utils.localization import langnames_to_langcodes
32 @@ -198,15 +198,6 @@ class Translations(POT): # {{{
36 - def freeze_locales(self):
37 - zf = self.DEST + '.zip'
38 - from calibre import CurrentDir
39 - from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
40 - with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
41 - with CurrentDir(self.DEST):
43 - shutil.rmtree(self.DEST)
47 return self.j(self.d(self.DEST), 'stats.pickle')
48 --- calibre/src/calibre/translations/dynamic.py.wiget 2013-12-06 05:13:34.000000000 +0100
49 +++ calibre/src/calibre/translations/dynamic.py 2013-12-09 09:28:32.349958101 +0100
50 @@ -5,10 +5,10 @@ Dynamic language lookup of translations
51 __license__ = 'GPL v3'
52 __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
56 from gettext import GNUTranslations
57 from calibre.utils.localization import get_lc_messages_path
58 -from zipfile import ZipFile
60 __all__ = ['translate']
62 @@ -21,15 +21,10 @@ def translate(lang, text):
64 mpath = get_lc_messages_path(lang)
66 - with ZipFile(P('localization/locales.zip',
67 - allow_user_override=False), 'r') as zf:
69 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
73 - trans = GNUTranslations(buf)
74 - _CACHE[lang] = trans
75 + p = os.path.join(mpath, 'messages.mo')
76 + if os.path.exists(p):
77 + trans = GNUTranslations(open(p, 'rb'))
78 + _CACHE[lang] = trans
80 return getattr(__builtins__, '_', lambda x: x)(text)
81 return trans.ugettext(text)
82 --- calibre/src/calibre/utils/localization.py.wiget 2013-12-06 05:13:34.000000000 +0100
83 +++ calibre/src/calibre/utils/localization.py 2013-12-09 09:31:05.694326467 +0100
84 @@ -74,20 +74,20 @@ def get_lang():
88 +def messages_path(lang):
89 + return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
91 def get_lc_messages_path(lang):
94 - if lang in available_translations():
97 - xlang = lang.split('_')[0].lower()
98 - if xlang in available_translations():
103 - return os.path.exists(P('localization/locales.zip',
104 - allow_user_override=False))
105 + if lang in available_translations():
108 + xlang = lang.split('_')[0]
109 + if xlang in available_translations():
111 + if hlang is not None:
112 + return messages_path(hlang)
117 @@ -114,18 +114,12 @@ def set_translators():
118 buf = cStringIO.StringIO(buf.getvalue())
120 if mpath is not None:
121 - from zipfile import ZipFile
122 - with ZipFile(P('localization/locales.zip',
123 - allow_user_override=False), 'r') as zf:
125 - buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
128 - isof = mpath + '/iso639.mo'
130 - iso639 = cStringIO.StringIO(zf.read(isof))
132 - pass # No iso639 translations for this lang
134 + buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
135 + mpath = mpath.replace(os.sep+'nds'+os.sep, os.sep+'de'+os.sep)
136 + isof = os.path.join(mpath, 'calibre_iso639.mo')
137 + if os.path.exists(isof):
138 + iso639 = open(isof, 'rb')
141 t = GNUTranslations(buf)