• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python msgfmt.make函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中msgfmt.make函数的典型用法代码示例。如果您正苦于以下问题:Python make函数的具体用法?Python make怎么用?Python make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了make函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: run

	def run(self):
		po_dir = os.path.join(os.path.dirname(os.curdir), 'template1')
		for path, names, filenames in os.walk(po_dir):
			for f in filenames:
				if f.endswith('.po'):
					lang = f[:len(f) - 3]
					src = os.path.join(path, f)
					dest_path = os.path.join('build', 'locale-langpack', lang, 'LC_MESSAGES')
					dest = os.path.join(dest_path, COMPILED_LANGUAGE_FILE)
					print('###########################################')
					print('###########################################')
					print('File: %s'%f)
					print('Language: %s'%lang)
					print(dest_path)
					print(dest)
					print('###########################################')
					print('###########################################')
					if not os.path.exists(dest_path):
						os.makedirs(dest_path)
					if not os.path.exists(dest):
						print 'Compiling %s' % src
						msgfmt.make(src, dest)
					else:
						src_mtime = os.stat(src)[8]
						dest_mtime = os.stat(dest)[8]
						if src_mtime > dest_mtime:
							print 'Compiling %s' % src
							msgfmt.make(src, dest)
开发者ID:atareao,项目名称:google-tasks-indicator,代码行数:28,代码来源:setup.py


示例2: run

    def run(self):
        po_dir = os.path.join(os.path.dirname(__file__), 'mirror/i18n/')

        if self.develop_mode:
            basedir = po_dir
        else:
            basedir = os.path.join(self.build_lib, 'mirror', 'i18n')

        print('Compiling po files from %s...' % po_dir),
        for path, names, filenames in os.walk(po_dir):
            for f in filenames:
                uptodate = False
                if f.endswith('.po'):
                    lang = f[:len(f) - 3]
                    src = os.path.join(path, f)
                    dest_path = os.path.join(basedir, lang, 'LC_MESSAGES')
                    dest = os.path.join(dest_path, 'mirror.mo')
                    if not os.path.exists(dest_path):
                        os.makedirs(dest_path)
                    if not os.path.exists(dest):
                        sys.stdout.write('%s, ' % lang)
                        sys.stdout.flush()
                        msgfmt.make(src, dest)
                    else:
                        src_mtime = os.stat(src)[8]
                        dest_mtime = os.stat(dest)[8]
                        if src_mtime > dest_mtime:
                            sys.stdout.write('%s, ' % lang)
                            sys.stdout.flush()
                            msgfmt.make(src, dest)
                        else:
                            uptodate = True
                if uptodate:
                    sys.stdout.write(' po files already up to date.  ')
        sys.stdout.write('\b\b \nFinished compiling translation files. \n')
开发者ID:ideal,项目名称:mirror,代码行数:35,代码来源:setup.py


示例3: run

 def run(self):
     """
        Compile all message catalogs .po files into .mo files.
        Skips not changed file based on source mtime.
     """
     # thanks to deluge guys ;)
     po_dir = os.path.join(os.path.dirname(__file__), 'webant', 'translations')
     print('Compiling po files from "{}"...'.format(po_dir))
     for lang in os.listdir(po_dir):
         sys.stdout.write("\tCompiling {}... ".format(lang))
         sys.stdout.flush()
         curr_lang_path = os.path.join(po_dir, lang)
         for path, dirs, filenames in os.walk(curr_lang_path):
             for f in filenames:
                 if f.endswith('.po'):
                     src = os.path.join(path, f)
                     dst = os.path.join(path, f[:-3] + ".mo")
                     if not os.path.exists(dst) or self.force:
                         msgfmt.make(src, dst)
                         print("ok.")
                     else:
                         src_mtime = os.stat(src)[8]
                         dst_mtime = os.stat(dst)[8]
                         if src_mtime > dst_mtime:
                             msgfmt.make(src, dst)
                             print("ok.")
                         else:
                             print("already up to date.")
     print('Finished compiling translation files.')
开发者ID:insomnia-lab,项目名称:libreant,代码行数:29,代码来源:setup.py


示例4: build_message_files

def build_message_files():
    """For each po/*.po, build .mo file in target locale directory"""
    for (_src, _dst) in list_message_files():
        _dst_dir = os.path.abspath(os.path.dirname(_dst))
        pmkdir(_dst_dir)
        _abs_file = os.path.abspath(_dst)
        print "Compiling %s -> %s" % (_src, _abs_file)
        msgfmt.make(_src, _abs_file)
开发者ID:d3ph,项目名称:pomodoro-indicator,代码行数:8,代码来源:compile_translations.py


示例5: compile_catalogs

 def compile_catalogs(self,codes):
     locales = self.locales_directory()
     for code in codes.split(','):
         path = os.path.join(locales,code,'LC_MESSAGES','messages.po')
         if not os.path.exists(path): continue
         
         dest = path.replace('.po','.mo')
         #run msgfmt on file...
         msgfmt.make(path,dest)
开发者ID:thraxil,项目名称:gtreed,代码行数:9,代码来源:__init__.py


示例6: build_message_files

 def build_message_files (self):
     """For each po/*.po, build .mo file in target locale directory."""
     # msgfmt.py is in the po/ subdirectory
     sys.path.append('po')
     import msgfmt
     for (src, dst) in list_message_files(self.distribution.get_name()):
         build_dst = os.path.join("build", dst)
         self.mkpath(os.path.dirname(build_dst))
         self.announce("Compiling %s -> %s" % (src, build_dst))
         msgfmt.make(src, build_dst)
开发者ID:Zearin,项目名称:linkchecker,代码行数:10,代码来源:setup.py


示例7: make_mo_files

def make_mo_files():
    """Utility function to generate MO files."""
    po_files = glob.glob(os.path.join(os.path.dirname(__file__), 'LC_MESSAGES', '*.po'))
    try:
        sys.path.append(os.path.join(os.path.dirname(sys.executable), "tools", "i18n"))
        import msgfmt
        for po_file in po_files:
            msgfmt.make(po_file, po_file.replace('.po', '.mo'))
    except (IOError, ImportError):
        pass
开发者ID:voyagersearch,项目名称:voyager-py,代码行数:10,代码来源:make_mo_files.py


示例8: run

 def run(self):
     self.announce('Building binary message catalog')
     if self.distribution.has_po_files():
         for mo, po in self.translations:
             dest = os.path.normpath(self.build_base + '/' + mo)
             self.mkpath(os.path.dirname(dest))
             if not self.force and not newer(po, dest):
                 self.announce("not building %s (up-to-date)" % dest)
             else:
                 msgfmt.make(po, dest)
开发者ID:BackupTheBerlios,项目名称:cctools-svn,代码行数:10,代码来源:straw_distutils.py


示例9: run

 def run(self):
     if not self.translations:
         return
     self.announce('Building binary message catalog')
     for mo, po in self.translations:
         dest = os.path.normpath( os.path.join(self.build_base, mo))
         self.mkpath(os.path.dirname(dest))
         if not self.force and not newer(po, dest):
             self.announce("not building %s (up-to-date)" % dest)
         else:
             msgfmt.make(po, dest)
开发者ID:Ichag,项目名称:openerp-client,代码行数:11,代码来源:mydistutils.py


示例10: run

 def run (self):
     self.mkpath(self.locale_dir)                    
     for po in glob.glob(os.path.join(self.po_dir, '*.po')):
         lang = os.path.splitext(os.path.basename(po))[0]
         gmo = po.replace('.po', '.gmo') 
         msgfmt.make(po, gmo) 
         destdir = os.path.join(self.locale_dir, lang, 'LC_MESSAGES')
         destfile = os.path.join(destdir, "jwsprocessor.mo")
         self.mkpath(destdir)
         self.copy_file(gmo, destfile)
         self.distribution.data_files.append( (destdir, [destfile]))
开发者ID:vhernandez,项目名称:jwsProcessor,代码行数:11,代码来源:setup.py


示例11: run

    def run(self):
        po_dir = os.path.join(os.path.dirname(__file__), 'deluge', 'i18n')

        if self.develop:
            basedir = po_dir
        else:
            basedir = os.path.join(self.build_lib, 'deluge', 'i18n')

        if not windows_check():
            intltool_merge = 'intltool-merge'
            intltool_merge_opts = '--utf8 --quiet'
            for data_file in (desktop_data, appdata_data):
                # creates the translated file from .in file.
                in_file = data_file + '.in'
                if 'xml' in data_file:
                    intltool_merge_opts += ' --xml-style'
                elif 'desktop' in data_file:
                    intltool_merge_opts += ' --desktop-style'

                print('Creating file: %s' % data_file)
                os.system('C_ALL=C ' + '%s ' * 5 % (
                    intltool_merge, intltool_merge_opts, po_dir, in_file, data_file))

        print('Compiling po files from %s...' % po_dir)
        for path, names, filenames in os.walk(po_dir):
            for f in filenames:
                upto_date = False
                if f.endswith('.po'):
                    lang = f[:len(f) - 3]
                    src = os.path.join(path, f)
                    dest_path = os.path.join(basedir, lang, 'LC_MESSAGES')
                    dest = os.path.join(dest_path, 'deluge.mo')
                    if not os.path.exists(dest_path):
                        os.makedirs(dest_path)
                    if not os.path.exists(dest):
                        sys.stdout.write('%s, ' % lang)
                        sys.stdout.flush()
                        msgfmt.make(src, dest)
                    else:
                        src_mtime = os.stat(src)[8]
                        dest_mtime = os.stat(dest)[8]
                        if src_mtime > dest_mtime:
                            sys.stdout.write('%s, ' % lang)
                            sys.stdout.flush()
                            msgfmt.make(src, dest)
                        else:
                            upto_date = True

        if upto_date:
            sys.stdout.write(' po files already upto date.  ')
        sys.stdout.write('\b\b \nFinished compiling translation files. \n')
开发者ID:deluge-torrent,项目名称:deluge,代码行数:51,代码来源:setup.py


示例12: rebuildmo

def rebuildmo():
    lang_glob = 'imdbpy-*.po'
    created = []
    for input_file in glob.glob(lang_glob):
        lang = input_file[7:-3]
        if not os.path.exists(lang):
            os.mkdir(lang)
        mo_dir = os.path.join(lang, 'LC_MESSAGES')
        if not os.path.exists(mo_dir):
            os.mkdir(mo_dir)
        output_file = os.path.join(mo_dir, 'imdbpy.mo')
        msgfmt.make(input_file, output_file)
        created.append(lang)
    return created
开发者ID:Elettronik,项目名称:SickRage,代码行数:14,代码来源:rebuildmo.py


示例13: run

	def run(self):
		for pofile in [f for f in os.listdir(PO_FOLDER) if f.endswith('.po')]:
			pofile = os.path.join(PO_FOLDER, pofile)
			modir, mofile = get_mopath(pofile)

			if not os.path.isdir(modir):
				os.makedirs(modir)

			if not os.path.isfile(mofile) or dep_util.newer(pofile, mofile):
				print 'compiling %s' % mofile
				msgfmt.make(pofile, mofile)
			else:
				#~ print 'skipping %s - up to date' % mofile
				pass
开发者ID:DarioGT,项目名称:Zim-QDA,代码行数:14,代码来源:setup.py


示例14: run

    def run(self):
        # Directory that contains the .po files
        po_dir = os.path.abspath(os.path.join(
                os.path.dirname(__file__), os.pardir, 'po'))
        # Build directory
        build_dir = os.path.abspath(os.path.join(
                os.path.dirname(__file__), os.pardir, 'build',
                    'textventures', 'locale'))
        # Create build directory if it does not exist
        if not os.path.exists(build_dir):
            os.makedirs(build_dir)

        # Loop the directory
        for path, names, filenames in os.walk(po_dir):
            for lang_file in filenames:
                # Check if .po files
                if lang_file.endswith('.po'):
                    # Get locale code
                    locale = lang_file[:-3]
                # Not a .po file
                else:
                    # Skip to next
                    continue

                lang_src = os.path.join(path, lang_file)
                # Set destination path
                lang_dst_dir = os.path.join(build_dir, locale,
                        'LC_MESSAGES')
                # Set destination file
                lang_dst_file = os.path.join(lang_dst_dir,
                        'textventures.mo')

                # Create directory if needed
                if not os.path.exists(lang_dst_dir):
                    os.makedirs(lang_dst_dir)

                # Compile translations
                if not os.path.exists(lang_dst_file):
                    print 'Compile ' + locale + '...'
                    msgfmt.make(lang_src, lang_dst_file)
                else:
                    # Check already existing translation to see if it
                    # needs to be recompiled.
                    src_mtime = os.stat(lang_src)[8]
                    dst_mtime = os.stat(lang_dst_file)[8]
                    if src_mtime > dst_mtime:
                        # Recompile
                        print 'Compile ' + locale + '...'
                        msgfmt.make(lang_src, lang_dst_file)
开发者ID:rmed,项目名称:textventures,代码行数:49,代码来源:build_trans.py


示例15: buildMessages

def buildMessages():
  # First we have to check which translations we have
  l=glob.glob('librapidsvn/src/locale/[a-z]*')
  dirs=[]
  for f in l:
    if os.path.isdir(f):
      dirs.append(f)
  for f in dirs:
    po=f+"/rapidsvn.po"
    mo=f+"/rapidsvn.mo"
    if os.path.isfile(po):
      # Clear dictionary that was used by msgfmt in previous conversion
      msgfmt.MESSAGES = {}
      print "Compiling message catalog %s into %s" % (po, mo)
      msgfmt.make(po,mo)
开发者ID:RapidSVN,项目名称:RapidSVN,代码行数:15,代码来源:create_nightly.py


示例16: run

    def run (self):
	"""Run msgfmt.make() on all_linguas."""
	if not self.all_linguas:
	    return

	for lingua in self.all_linguas:
	    pofile = os.path.join('po', lingua + '.po')
	    outdir = os.path.join(self.build_dir, lingua, 'LC_MESSAGES')
            self.mkpath(outdir)
	    outfile = os.path.join(outdir, 'gaphor.mo')
	    if self.force or newer(pofile, outfile):
                print 'converting %s -> %s' % (pofile, outfile)
		msgfmt.make(pofile, outfile)
            else:
                print 'not converting %s (output up-to-date)' % pofile
开发者ID:Nyox,项目名称:gaphor,代码行数:15,代码来源:build_mo.py


示例17: main

def main():
    parser = OptionParser(usage="usage: %prog [options]",
                          version="%prog 1.0")
    parser.add_option("-l", "--lang",
                      action="store", # optional because action defaults to "store"
                      dest="lang",
                      help="Choose a language for compiling *.po files to *.mo",)
    (options, args) = parser.parse_args()

    if len(args) != 0:
        parser.error("wrong number of arguments, you only have to use lang option")

    os.chdir(os.path.join(os.getcwd(), "translated", options.lang))
    for filename in glob.glob("*.po"):
        msgfmt.make(filename, os.path.join("LC_MESSAGES", filename.split(".")[0] + ".mo"))
开发者ID:Jenselme,项目名称:docs,代码行数:15,代码来源:i18n_win.py


示例18: run

	def run(self):
		for path, names, filenames in os.walk('./po'):
			for f in filenames:
				if f.endswith('.po'):
					lang = f[:-3]
					src = os.path.join(path, f)
					dest_path = os.path.join('build', 'locale',
						lang, 'LC_MESSAGES')
					dest = os.path.join(dest_path, 'OrajeApplet.mo')
					if not os.path.exists(dest_path):
						os.makedirs(dest_path)
					print 'Compiling %s' % src
					msgfmt.make(src, dest)

		_build.run(self)
开发者ID:reidrac,项目名称:orajeweather,代码行数:15,代码来源:setup.py


示例19: run

    def run(self):
        po_dir = os.path.join(os.path.dirname(__file__), 'deluge/i18n/')

        if self.develop_mode:
            basedir = po_dir
        else:
            basedir = os.path.join(self.build_lib, 'deluge', 'i18n')

        if not windows_check():
            # creates the translated desktop file
            INTLTOOL_MERGE='intltool-merge'
            INTLTOOL_MERGE_OPTS='--utf8 --quiet --desktop-style'
            desktop_in='deluge/ui/data/share/applications/deluge.desktop.in'
            desktop_data='deluge/ui/data/share/applications/deluge.desktop'
            print('Creating desktop file: %s' % desktop_data)
            os.system('C_ALL=C ' + '%s '*5 % (INTLTOOL_MERGE, INTLTOOL_MERGE_OPTS, \
                        po_dir, desktop_in, desktop_data))

        print('Compiling po files from %s...' % po_dir),
        for path, names, filenames in os.walk(po_dir):
            for f in filenames:
                uptoDate = False
                if f.endswith('.po'):
                    lang = f[:len(f) - 3]
                    src = os.path.join(path, f)
                    dest_path = os.path.join(basedir, lang, 'LC_MESSAGES')
                    dest = os.path.join(dest_path, 'deluge.mo')
                    if not os.path.exists(dest_path):
                        os.makedirs(dest_path)
                    if not os.path.exists(dest):
                        sys.stdout.write('%s, ' % lang)
                        sys.stdout.flush()
                        msgfmt.make(src, dest)
                    else:
                        src_mtime = os.stat(src)[8]
                        dest_mtime = os.stat(dest)[8]
                        if src_mtime > dest_mtime:
                            sys.stdout.write('%s, ' % lang)
                            sys.stdout.flush()
                            msgfmt.make(src, dest)
                        else:
                            uptoDate = True

        if uptoDate:
            sys.stdout.write(' po files already upto date.  ')
        sys.stdout.write('\b\b \nFinished compiling translation files. \n')
开发者ID:cheuschober,项目名称:deluge,代码行数:46,代码来源:setup.py


示例20: compileCatalog

def compileCatalog(catalog_path):
    """Compile the .po file specified by <catalog_path> to a binary gettext
    catalog.  The resulting binary catalog is placed in the same directory
    as the .po file."""

    import msgfmt

    # compile the catalog using msgfmt
    return msgfmt.make(catalog_path,
                       os.path.splitext(catalog_path)[0] + ".mo")
开发者ID:BackupTheBerlios,项目名称:cctools-svn,代码行数:10,代码来源:catalog.py



注:本文中的msgfmt.make函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python msgpack.dump函数代码示例发布时间:2022-05-27
下一篇:
Python msg_logger.MSGLogger类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap