コード例 #1
0
ファイル: translations.py プロジェクト: aimylios/calibre
 def action_per_file(f):
     locale, dest = fmap[f]
     ln = normalize_locale(locale).partition('.')[0]
     if ln in lcdata:
         ld = lcdata[ln]
         lcdest = self.j(self.d(dest), 'lcdata.pickle')
         with open(lcdest, 'wb') as lcf:
             lcf.write(cPickle.dumps(ld, -1))
コード例 #2
0
 def action_per_file(f):
     locale, dest = fmap[f]
     ln = normalize_locale(locale).partition('.')[0]
     if ln in lcdata:
         ld = lcdata[ln]
         lcdest = self.j(self.d(dest), 'lcdata.pickle')
         with open(lcdest, 'wb') as lcf:
             lcf.write(cPickle.dumps(ld, -1))
コード例 #3
0
ファイル: translations.py プロジェクト: smdx023/calibre
 def action_per_file(f):
     locale, dest = fmap[f]
     ln = normalize_locale(locale).partition('.')[0]
     if ln in lcdata:
         ld = lcdata[ln]
         lcdest = self.j(self.d(dest), 'lcdata.calibre_msgpack')
         from calibre.utils.serialize import msgpack_dumps
         with open(lcdest, 'wb') as lcf:
             lcf.write(msgpack_dumps(ld))
コード例 #4
0
ファイル: translations.py プロジェクト: NiLuJe/calibre
 def action_per_file(f):
     locale, dest = fmap[f]
     ln = normalize_locale(locale).partition('.')[0]
     if ln in lcdata:
         ld = lcdata[ln]
         lcdest = self.j(self.d(dest), 'lcdata.calibre_msgpack')
         from calibre.utils.serialize import msgpack_dumps
         with open(lcdest, 'wb') as lcf:
             lcf.write(msgpack_dumps(ld))
コード例 #5
0
    def run(self, opts):
        self.compile_content_server_translations()
        l = {}
        exec(
            compile(
                open(
                    os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 'lc_data.py')).read(),
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             'lc_data.py'), 'exec'), l, l)
        lcdata = {k: {k1: v1 for k1, v1 in v} for k, v in l['data']}
        self.iso639_errors = []
        jobs = []
        for f in self.po_files():
            locale, dest = self.mo_file(f)
            base = os.path.dirname(dest)
            if not os.path.exists(base):
                os.makedirs(base)
            jobs.append(['msgfmt', '-o', dest, f])
            iscpo = {'bn': 'bn_IN', 'zh_HK': 'zh_CN'}.get(locale, locale)
            iso639 = self.j(self.TRANSLATIONS, 'iso_639', '%s.po' % iscpo)

            if os.path.exists(iso639) and self.check_iso639(iso639):
                dest = self.j(self.d(dest), 'iso639.mo')
                if self.newer(dest, iso639):
                    jobs.append(['msgfmt', '-o', dest, iso639])
            elif locale not in {
                    'en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc', 'ltg', 'nds',
                    'te', 'yi', 'fo', 'sq', 'ast', 'ml', 'ku', 'fr_CA', 'him',
                    'jv', 'ka', 'fur', 'ber', 'my', 'fil', 'hy', 'ug'
            }:
                self.warn('No ISO 639 translations for locale:', locale)

            ln = normalize_locale(locale).partition('.')[0]
            if ln in lcdata:
                ld = lcdata[ln]
                lcdest = self.j(self.d(dest), 'lcdata.pickle')
                with open(lcdest, 'wb') as lcf:
                    lcf.write(cPickle.dumps(ld, -1))
        self.info('\nCompiling %d translation files...' % len(jobs))
        tuple(parallel_check_output(jobs, self.info))

        if self.iso639_errors:
            for err in self.iso639_errors:
                print(err)
            raise SystemExit(1)

        self.write_stats()
        self.freeze_locales()
        self.compile_user_manual_translations()
コード例 #6
0
ファイル: translations.py プロジェクト: AEliu/calibre
    def run(self, opts):
        self.compile_content_server_translations()
        l = {}
        exec(compile(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lc_data.py'))
             .read(), os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lc_data.py'), 'exec'), l, l)
        lcdata = {k:{k1:v1 for k1, v1 in v} for k, v in l['data']}
        self.iso639_errors = []
        jobs = []
        for f in self.po_files():
            locale, dest = self.mo_file(f)
            base = os.path.dirname(dest)
            if not os.path.exists(base):
                os.makedirs(base)
            jobs.append(['msgfmt', '-o', dest, f])
            iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
            iso639 = self.j(self.TRANSLATIONS, 'iso_639', '%s.po'%iscpo)

            if os.path.exists(iso639) and self.check_iso639(iso639):
                dest = self.j(self.d(dest), 'iso639.mo')
                if self.newer(dest, iso639):
                    jobs.append(['msgfmt', '-o', dest, iso639])
            elif locale not in {
                'en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc', 'ltg', 'nds',
                'te', 'yi', 'fo', 'sq', 'ast', 'ml', 'ku', 'fr_CA', 'him',
                'jv', 'ka', 'fur', 'ber', 'my', 'fil', 'hy', 'ug'}:
                self.warn('No ISO 639 translations for locale:', locale)

            ln = normalize_locale(locale).partition('.')[0]
            if ln in lcdata:
                ld = lcdata[ln]
                lcdest = self.j(self.d(dest), 'lcdata.pickle')
                with open(lcdest, 'wb') as lcf:
                    lcf.write(cPickle.dumps(ld, -1))
        self.info('\nCompiling %d translation files...' % len(jobs))
        tuple(parallel_check_output(jobs, self.info))

        if self.iso639_errors:
            for err in self.iso639_errors:
                print (err)
            raise SystemExit(1)

        self.write_stats()
        self.freeze_locales()
        self.compile_user_manual_translations()
コード例 #7
0
ファイル: translations.py プロジェクト: Hainish/calibre
    def run(self, opts):
        l = {}
        execfile(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'lc_data.py'), l, l)
        lcdata = {k: {k1: v1 for k1, v1 in v} for k, v in l['data']}
        self.iso639_errors = []
        for f in self.po_files():
            locale, dest = self.mo_file(f)
            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])
            iscpo = {'bn': 'bn_IN', 'zh_HK': 'zh_CN'}.get(locale, locale)
            iso639 = self.j(self.LP_ISO_PATH, '%s.po' % iscpo)

            if os.path.exists(iso639):
                self.check_iso639(iso639)
                dest = self.j(self.d(dest), 'iso639.mo')
                if self.newer(dest, iso639):
                    self.info('\tCopying ISO 639 translations for %s' % iscpo)
                    subprocess.check_call(['msgfmt', '-o', dest, iso639])
            elif locale not in {
                    'en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc', 'ltg', 'nds',
                    'te', 'yi', 'fo', 'sq', 'ast', 'ml', 'ku', 'fr_CA', 'him',
                    'jv', 'ka', 'fur', 'ber', 'my', 'fil'
            }:
                self.warn('No ISO 639 translations for locale:', locale)

            ln = normalize_locale(locale).partition('.')[0]
            if ln in lcdata:
                ld = lcdata[ln]
                lcdest = self.j(self.d(dest), 'lcdata.pickle')
                with open(lcdest, 'wb') as lcf:
                    lcf.write(cPickle.dumps(ld, -1))

        if self.iso639_errors:
            for err in self.iso639_errors:
                print(err)
            raise SystemExit(1)

        self.write_stats()
        self.freeze_locales()
コード例 #8
0
ファイル: translations.py プロジェクト: lovesuri/calibre
    def run(self, opts):
        l = {}
        exec(compile(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lc_data.py'))
             .read(), os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lc_data.py'), 'exec'), l, l)
        lcdata = {k:{k1:v1 for k1, v1 in v} for k, v in l['data']}
        self.iso639_errors = []
        for f in self.po_files():
            locale, dest = self.mo_file(f)
            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])
            iscpo = {'bn':'bn_IN', 'zh_HK':'zh_CN'}.get(locale, locale)
            iso639 = self.j(self.LP_ISO_PATH, '%s.po'%iscpo)

            if os.path.exists(iso639):
                self.check_iso639(iso639)
                dest = self.j(self.d(dest), 'iso639.mo')
                if self.newer(dest, iso639):
                    self.info('\tCopying ISO 639 translations for %s' % iscpo)
                    subprocess.check_call(['msgfmt', '-o', dest, iso639])
            elif locale not in {
                'en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc', 'ltg', 'nds',
                'te', 'yi', 'fo', 'sq', 'ast', 'ml', 'ku', 'fr_CA', 'him',
                'jv', 'ka', 'fur', 'ber', 'my', 'fil'}:
                self.warn('No ISO 639 translations for locale:', locale)

            ln = normalize_locale(locale).partition('.')[0]
            if ln in lcdata:
                ld = lcdata[ln]
                lcdest = self.j(self.d(dest), 'lcdata.pickle')
                with open(lcdest, 'wb') as lcf:
                    lcf.write(cPickle.dumps(ld, -1))

        if self.iso639_errors:
            for err in self.iso639_errors:
                print (err)
            raise SystemExit(1)

        self.write_stats()
        self.freeze_locales()