本文整理汇总了Python中msgfmt.make函数的典型用法代码示例。如果您正苦于以下问题:Python make函数的具体用法?Python make怎么用?Python make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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')
示例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.')
示例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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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]))
示例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')
示例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
示例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
示例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)
示例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)