]> git.pld-linux.org Git - packages/calibre.git/blobdiff - calibre-locales.patch
- started update to 2.5.0
[packages/calibre.git] / calibre-locales.patch
index a15bd92e63a87f0e2f0808436f4e0502c04d4eae..7a186cda1ba101dd4867f6b45ae9cf36bc43c57a 100644 (file)
@@ -1,9 +1,90 @@
---- calibre/src/calibre/utils/localization.py~  2012-01-20 05:44:58.000000000 +0100
-+++ calibre/src/calibre/utils/localization.py   2012-01-24 20:40:09.619382280 +0100
-@@ -49,20 +49,20 @@
+--- calibre/setup/translations.py.wiget        2013-12-06 05:13:34.000000000 +0100
++++ calibre/setup/translations.py      2013-12-09 09:28:32.349958101 +0100
+@@ -143,7 +143,7 @@ class Translations(POT):  # {{{
+     def mo_file(self, po_file):
+         locale = os.path.splitext(os.path.basename(po_file))[0]
+-        return locale, os.path.join(self.DEST, locale, 'messages.mo')
++        return locale, os.path.join(self.DEST, locale, 'LC_MESSAGES', 'messages.mo')
+     def run(self, opts):
+         self.iso639_errors = []
+@@ -152,8 +152,9 @@ class Translations(POT):  # {{{
+             base = os.path.dirname(dest)
+             if not os.path.exists(base):
+                 os.makedirs(base)
+-            self.info('\tCompiling translations for', locale)
+-            subprocess.check_call(['msgfmt', '-o', dest, f])
++            if self.newer(dest, f):
++                self.info('\tCompiling translations for', locale)
++                subprocess.check_call(['msgfmt', '-o', dest, f])
+             iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
+             iso639 = self.j(self.LP_ISO_PATH, '%s.po'%iscpo)
+@@ -174,7 +175,6 @@ class Translations(POT):  # {{{
+             raise SystemExit(1)
+         self.write_stats()
+-        self.freeze_locales()
+     def check_iso639(self, path):
+         from calibre.utils.localization import langnames_to_langcodes
+@@ -198,15 +198,6 @@ class Translations(POT):  # {{{
+                     # raise SystemExit(1)
+                 rmap[msgstr] = msgid
+-    def freeze_locales(self):
+-        zf = self.DEST + '.zip'
+-        from calibre import CurrentDir
+-        from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
+-        with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
+-            with CurrentDir(self.DEST):
+-                zf.add_dir('.')
+-        shutil.rmtree(self.DEST)
+-
+     @property
+     def stats(self):
+         return self.j(self.d(self.DEST), 'stats.pickle')
+--- calibre/src/calibre/translations/dynamic.py.wiget  2013-12-06 05:13:34.000000000 +0100
++++ calibre/src/calibre/translations/dynamic.py        2013-12-09 09:28:32.349958101 +0100
+@@ -5,10 +5,10 @@ Dynamic language lookup of translations
+ __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
+-from zipfile import ZipFile
+ __all__ = ['translate']
+@@ -21,15 +21,10 @@ def translate(lang, text):
+     else:
+         mpath = get_lc_messages_path(lang)
+         if mpath is not None:
+-            with ZipFile(P('localization/locales.zip',
+-                allow_user_override=False), 'r') as zf:
+-                try:
+-                    buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
+-                except:
+-                    pass
+-                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
+     if trans is None:
+         return getattr(__builtins__, '_', lambda x: x)(text)
+     return trans.ugettext(text)
+--- calibre/src/calibre/utils/localization.py.wiget    2013-12-06 05:13:34.000000000 +0100
++++ calibre/src/calibre/utils/localization.py  2013-12-09 09:31:05.694326467 +0100
+@@ -74,20 +74,20 @@ def get_lang():
          lang = 'en'
      return lang
-
 +def messages_path(lang):
 +    return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
 +
@@ -13,7 +94,7 @@
 -        if lang in available_translations():
 -            hlang = lang
 -        else:
--            xlang = lang.split('_')[0]
+-            xlang = lang.split('_')[0].lower()
 -            if xlang in available_translations():
 -                hlang = xlang
 -    return hlang
 +        xlang = lang.split('_')[0]
 +        if xlang in available_translations():
 +            hlang = xlang
-+    if hlang is not None:
-+            if hlang is not None:
-+    return None
-
- def set_translators():
-     # To test different translations invoke as
-@@ -84,18 +84,12 @@
++        if hlang is not None:
++            return messages_path(hlang)
++        return None
+ _lang_trans = None
+@@ -114,18 +114,12 @@ def set_translators():
                  buf = cStringIO.StringIO(buf.getvalue())
-
          if mpath is not None:
 -            from zipfile import ZipFile
 -            with ZipFile(P('localization/locales.zip',
 -                try:
 -                    iso639 = cStringIO.StringIO(zf.read(isof))
 -                except:
--                    pass # No iso639 translations for this lang
+-                    pass  # No iso639 translations for this lang
 +            if buf is None:
 +                buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
 +            mpath = mpath.replace(os.sep+'nds'+os.sep, os.sep+'de'+os.sep)
 +            isof = os.path.join(mpath, 'calibre_iso639.mo')
-+            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.orig    2012-01-20 05:44:58.000000000 +0100
-+++ calibre/src/calibre/translations/dynamic.py 2012-01-24 20:58:25.892606042 +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
--from zipfile import ZipFile
-
- __all__ = ['translate']
-
-@@ -21,15 +21,10 @@
-     else:
-         mpath = get_lc_messages_path(lang)
-         if mpath is not None:
--            with ZipFile(P('localization/locales.zip',
--                allow_user_override=False), 'r') as zf:
--                try:
--                    buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
--                except:
--                    pass
--                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
-     if trans is None:
-         return getattr(__builtins__, '_', lambda x: x)(text)
-     return trans.ugettext(text)
---- 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]
--        return locale, os.path.join(self.DEST, locale, 'messages.mo')
-+        return locale, os.path.join(self.DEST, locale, 'LC_MESSAGES', 'messages.mo')
-     def run(self, opts):
-         for f in self.po_files():
-@@ -139,8 +139,9 @@
-             base = os.path.dirname(dest)
-             if not os.path.exists(base):
-                 os.makedirs(base)
--            self.info('\tCompiling translations for', locale)
--            subprocess.check_call(['msgfmt', '-o', dest, f])
-+            if self.newer(dest, f):
-+                self.info('\tCompiling translations for', locale)
-+                subprocess.check_call(['msgfmt', '-o', dest, f])
-             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()
--
--    def freeze_locales(self):
--        zf = self.DEST + '.zip'
--        from calibre import CurrentDir
--        from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
--        with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
--            with CurrentDir(self.DEST):
--                zf.add_dir('.')
--        shutil.rmtree(self.DEST)
-     @property
-     def stats(self):
+         if buf is not None:
+             t = GNUTranslations(buf)
This page took 0.040548 seconds and 4 git commands to generate.