---- calibre/src/calibre/utils/localization.py.orig 2011-07-15 18:54:35.000000000 +0200
-+++ calibre/src/calibre/utils/localization.py 2011-07-18 13:53:51.356353825 +0200
-@@ -8,7 +8,6 @@
-
- import os, locale, re, cStringIO, cPickle
- from gettext import GNUTranslations, NullTranslations
--from zipfile import ZipFile
-
- _available_translations = None
-
-@@ -50,20 +49,20 @@
+--- calibre/src/calibre/utils/localization.py~ 2012-01-13 05:32:13.000000000 +0100
++++ calibre/src/calibre/utils/localization.py 2012-01-17 09:35:01.311333439 +0100
+@@ -49,20 +49,20 @@
lang = 'en'
return lang
-
+
+def messages_path(lang):
+ return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
+
+ xlang = lang.split('_')[0]
+ if xlang in available_translations():
+ hlang = xlang
-+ if hlang is not None:
-+ return messages_path(hlang)
-+ return None
-
++ if hlang is not None:
++ return messages_path(hlang)
++ return None
+
def set_translators():
# To test different translations invoke as
-@@ -79,17 +78,12 @@
-
- mpath = get_lc_messages_path(lang)
+@@ -84,18 +84,12 @@
+ buf = cStringIO.StringIO(buf.getvalue())
+
if mpath is not None:
+- from zipfile import ZipFile
- with ZipFile(P('localization/locales.zip',
- allow_user_override=False), 'r') as zf:
- if buf is None:
+ isof = os.path.join(mpath, 'calibre_iso639.mo')
+ if os.path.exists(isof):
+ iso639 = open(isof, 'rb')
-
+
t = None
if buf is not None:
---- calibre/src/calibre/translations/dynamic.py~ 2011-06-24 20:01:27.000000000 +0200
-+++ calibre/src/calibre/translations/dynamic.py 2011-06-29 10:37:52.305747266 +0200
-@@ -5,9 +5,10 @@
+--- calibre/src/calibre/translations/dynamic.py.orig 2012-01-13 05:32:13.000000000 +0100
++++ calibre/src/calibre/translations/dynamic.py 2012-01-17 09:37:53.594649557 +0100
+@@ -5,10 +5,10 @@
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
-
+
+import os
import cStringIO
from gettext import GNUTranslations
--from calibre.utils.localization import get_lc_messages_path, ZipFile
-+from calibre.utils.localization import get_lc_messages_path
-
+ from calibre.utils.localization import get_lc_messages_path
+-from zipfile import ZipFile
+
__all__ = ['translate']
-
-@@ -20,15 +21,10 @@
+
+@@ -21,15 +21,10 @@
else:
mpath = get_lc_messages_path(lang)
if mpath is not None:
- else:
- trans = GNUTranslations(buf)
- _CACHE[lang] = trans
-+ p = os.path.join(mpath, 'messages.mo')
-+ if os.path.exists(p):
-+ trans = GNUTranslations(open(p, 'rb'))
-+ _CACHE[lang] = trans
++ p = os.path.join(mpath, 'messages.mo')
++ if os.path.exists(p):
++ trans = GNUTranslations(open(p, 'rb'))
++ _CACHE[lang] = trans
if trans is None:
return getattr(__builtins__, '_', lambda x: x)(text)
return trans.ugettext(text)
---- calibre/setup/translations.py.orig 2011-07-15 18:54:35.000000000 +0200
-+++ calibre/setup/translations.py 2011-07-18 13:57:58.791853837 +0200
-@@ -132,7 +132,7 @@
+--- calibre/setup/translations.py.orig 2011-08-26 18:36:51.000000000 +0200
++++ calibre/setup/translations.py 2011-08-27 12:55:49.997229244 +0200
+@@ -131,7 +131,7 @@
def mo_file(self, po_file):
locale = os.path.splitext(os.path.basename(po_file))[0]
def run(self, opts):
for f in self.po_files():
-@@ -140,8 +140,9 @@
+@@ -139,8 +139,9 @@
base = os.path.dirname(dest)
if not os.path.exists(base):
os.makedirs(base)
+ if self.newer(dest, f):
+ self.info('\tCompiling translations for', locale)
+ subprocess.check_call(['msgfmt', '-o', dest, f])
- if locale in ('en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc', 'ltg', 'nds', 'te', 'yi'):
- continue
- pycountry = self.j(sysconfig.get_python_lib(), 'pycountry',
-@@ -157,16 +158,6 @@
- '\nDo you have pycountry installed?')
+ iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
+ iso639 = self.j(self.d(self.SRC), 'setup', 'iso_639',
+ '%s.po'%iscpo)
+@@ -155,16 +156,6 @@
+ self.warn('No ISO 639 translations for locale:', locale)
self.write_stats()
- self.freeze_locales()