]> git.pld-linux.org Git - packages/calibre.git/blame - calibre-locales.patch
- release 5 (by relup.sh)
[packages/calibre.git] / calibre-locales.patch
CommitLineData
b65e37c7 1--- calibre/src/calibre/utils/localization.py~ 2012-01-13 05:32:13.000000000 +0100
2+++ calibre/src/calibre/utils/localization.py 2012-01-17 09:35:01.311333439 +0100
7f3c43c5 3@@ -49,20 +49,20 @@
5cfefa9c 4 lang = 'en'
5 return lang
b65e37c7 6
e69f76cd
JK
7+def messages_path(lang):
8+ return ('/usr/share/locale/%s/LC_MESSAGES'%lang)
5cfefa9c 9+
10 def get_lc_messages_path(lang):
11 hlang = None
12- if zf_exists():
13- if lang in available_translations():
14- hlang = lang
15- else:
16- xlang = lang.split('_')[0]
17- if xlang in available_translations():
18- hlang = xlang
19- return hlang
20-
21-def zf_exists():
22- return os.path.exists(P('localization/locales.zip',
23- allow_user_override=False))
24+ if lang in available_translations():
25+ hlang = lang
26+ else:
27+ xlang = lang.split('_')[0]
28+ if xlang in available_translations():
29+ hlang = xlang
b65e37c7 30+ if hlang is not None:
31+ return messages_path(hlang)
32+ return None
33
5cfefa9c 34 def set_translators():
35 # To test different translations invoke as
7f3c43c5 36@@ -84,18 +84,12 @@
37 buf = cStringIO.StringIO(buf.getvalue())
b65e37c7 38
5cfefa9c 39 if mpath is not None:
7f3c43c5 40- from zipfile import ZipFile
5cfefa9c 41- with ZipFile(P('localization/locales.zip',
42- allow_user_override=False), 'r') as zf:
43- if buf is None:
44- buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
45- if mpath == 'nds':
46- mpath = 'de'
47- isof = mpath + '/iso639.mo'
48- try:
49- iso639 = cStringIO.StringIO(zf.read(isof))
50- except:
51- pass # No iso639 translations for this lang
52+ if buf is None:
53+ buf = open(os.path.join(mpath, 'calibre.mo'), 'rb')
54+ mpath = mpath.replace(os.sep+'nds'+os.sep, os.sep+'de'+os.sep)
55+ isof = os.path.join(mpath, 'calibre_iso639.mo')
b65e37c7 56+ if os.path.exists(isof):
5cfefa9c 57+ iso639 = open(isof, 'rb')
b65e37c7 58
b0e4d610 59 t = None
5cfefa9c 60 if buf is not None:
b65e37c7 61--- calibre/src/calibre/translations/dynamic.py.orig 2012-01-13 05:32:13.000000000 +0100
62+++ calibre/src/calibre/translations/dynamic.py 2012-01-17 09:37:53.594649557 +0100
7f3c43c5 63@@ -5,10 +5,10 @@
5cfefa9c 64 __license__ = 'GPL v3'
65 __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
7f3c43c5 66
5cfefa9c 67+import os
68 import cStringIO
69 from gettext import GNUTranslations
7f3c43c5 70 from calibre.utils.localization import get_lc_messages_path
71-from zipfile import ZipFile
72
5cfefa9c 73 __all__ = ['translate']
7f3c43c5 74
75@@ -21,15 +21,10 @@
5cfefa9c 76 else:
77 mpath = get_lc_messages_path(lang)
78 if mpath is not None:
79- with ZipFile(P('localization/locales.zip',
80- allow_user_override=False), 'r') as zf:
81- try:
82- buf = cStringIO.StringIO(zf.read(mpath + '/messages.mo'))
83- except:
84- pass
85- else:
86- trans = GNUTranslations(buf)
87- _CACHE[lang] = trans
7f3c43c5 88+ p = os.path.join(mpath, 'messages.mo')
89+ if os.path.exists(p):
90+ trans = GNUTranslations(open(p, 'rb'))
91+ _CACHE[lang] = trans
5cfefa9c 92 if trans is None:
93 return getattr(__builtins__, '_', lambda x: x)(text)
94 return trans.ugettext(text)
e060118c 95--- calibre/setup/translations.py.orig 2011-08-26 18:36:51.000000000 +0200
96+++ calibre/setup/translations.py 2011-08-27 12:55:49.997229244 +0200
97@@ -131,7 +131,7 @@
5cfefa9c 98
99 def mo_file(self, po_file):
100 locale = os.path.splitext(os.path.basename(po_file))[0]
101- return locale, os.path.join(self.DEST, locale, 'messages.mo')
102+ return locale, os.path.join(self.DEST, locale, 'LC_MESSAGES', 'messages.mo')
103
5cfefa9c 104 def run(self, opts):
b0e4d610 105 for f in self.po_files():
e060118c 106@@ -139,8 +139,9 @@
5cfefa9c 107 base = os.path.dirname(dest)
108 if not os.path.exists(base):
109 os.makedirs(base)
110- self.info('\tCompiling translations for', locale)
111- subprocess.check_call(['msgfmt', '-o', dest, f])
112+ if self.newer(dest, f):
113+ self.info('\tCompiling translations for', locale)
114+ subprocess.check_call(['msgfmt', '-o', dest, f])
e060118c 115 iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
116 iso639 = self.j(self.d(self.SRC), 'setup', 'iso_639',
117 '%s.po'%iscpo)
118@@ -155,16 +156,6 @@
119 self.warn('No ISO 639 translations for locale:', locale)
5cfefa9c 120
121 self.write_stats()
122- self.freeze_locales()
123-
124- def freeze_locales(self):
125- zf = self.DEST + '.zip'
126- from calibre import CurrentDir
127- from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
128- with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
129- with CurrentDir(self.DEST):
130- zf.add_dir('.')
131- shutil.rmtree(self.DEST)
132
133 @property
134 def stats(self):
This page took 0.083124 seconds and 4 git commands to generate.