예제 #1
0
def build_mo_files():
    """Compile avalaible localization files"""

    APP = "nested"
    locale_dir = 'mo'
    po_dir = 'po'

    if os.path.exists(locale_dir):
        shutil.rmtree(locale_dir)
    os.mkdir(locale_dir)

    available_langs = os.listdir(po_dir)
    available_langs = filter(lambda file: file.endswith('.po'),
                             available_langs)
    available_langs = map(lambda file: file[:-3], available_langs)

    print 'Languages: ', available_langs

    for lang in available_langs:
        po_file = os.path.join(po_dir, lang + '.po')
        lang_dir = os.path.join(locale_dir, lang)
        mo_dir = os.path.join(lang_dir, 'LC_MESSAGES')
        mo_file = os.path.join(mo_dir, APP + '.mo')

        if not os.path.exists(mo_dir):
            os.makedirs(mo_dir)

        print('Compiling {0} to {1}'.format(po_file, mo_file))
        msgfmt.make(po_file, mo_file)
예제 #2
0
	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)
예제 #3
0
파일: setup.py 프로젝트: ideal/mirror
    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')
예제 #4
0
    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')
예제 #5
0
파일: setup.py 프로젝트: maxigas/libreant
 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.')
예제 #6
0
 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)
예제 #7
0
파일: setup.py 프로젝트: salphaon/dockbarx
 def run(self):
     po_dict = {
         "dockbarx":
         os.path.join(os.path.dirname(os.curdir), "po"),
         "dockbarx-themes":
         os.path.join(os.path.dirname(os.curdir), "po-themes")
     }
     for (mo_file, po_dir) in po_dict.items():
         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", lang,
                                              "LC_MESSAGES")
                     dest = os.path.join(dest_path, "%s.mo" % mo_file)
                     if not os.path.exists(dest_path):
                         os.makedirs(dest_path)
                     if not os.path.exists(dest):
                         print "Compiling %s for %s" % (src, mo_file)
                         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 for %s" % (src, mo_file)
                             msgfmt.make(src, dest)
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)
예제 #9
0
파일: __init__.py 프로젝트: thraxil/gtreed
 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)
 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)
예제 #11
0
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
예제 #12
0
파일: setup.py 프로젝트: Zearin/linkchecker
 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)
예제 #13
0
 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)
예제 #14
0
    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)
예제 #15
0
 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)
예제 #16
0
    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')
예제 #17
0
 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)
예제 #18
0
 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]))
예제 #19
0
 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]))
예제 #20
0
 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)
예제 #21
0
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
예제 #22
0
    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')
예제 #23
0
파일: setup.py 프로젝트: hjq300/zim-wiki
    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
예제 #24
0
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
예제 #25
0
파일: setup.py 프로젝트: DarioGT/Zim-QDA
	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
예제 #26
0
    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)
예제 #27
0
파일: i18n_win.py 프로젝트: Jenselme/docs
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"))
예제 #28
0
파일: build_mo.py 프로젝트: Nyox/gaphor
    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
예제 #29
0
	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)
예제 #30
0
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)
예제 #31
0
파일: build_mo.py 프로젝트: xqbumu/gaphor
    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
예제 #32
0
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)
예제 #33
0
    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.MESSAGES.clear(
                )  # prevent "spill over" between translations - see github #664
                msgfmt.make(pofile, mofile)
            else:
                #~ print('skipping %s - up to date' % mofile)
                pass
예제 #34
0
파일: setup.py 프로젝트: cheuschober/deluge
    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')
예제 #35
0
파일: setup.py 프로젝트: cheuschober/deluge
    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')
예제 #36
0
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")
예제 #37
0
 def run(self):
     po_dir = os.path.join(self.trans_base, self.trans_dir)
     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(self.trans_dist, lang, 'LC_MESSAGES')
                 dest = os.path.join(dest_path, self.trans_domain)
                 if not os.path.exists(dest_path):
                     os.makedirs(dest_path)
                 if not os.path.exists(dest):
                     print 'Compiling locale %s to %s' % (src, dest)
                     msgfmt.make(src, dest)
                 else:
                     src_mtime = os.stat(src)[8]
                     dest_mtime = os.stat(dest)[8]
                     if src_mtime > dest_mtime:
                         print 'Compiling locale %s to %s' % (src, dest)
                         msgfmt.make(src, dest)
예제 #38
0
파일: setup.py 프로젝트: kofei/librarian
 def run(self):
     po_dir = os.path.join(os.path.dirname(os.curdir), 'src/po')
     for path, names, filenames in os.walk(po_dir):
         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, 'librarian.mo')
                 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)
예제 #39
0
 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)
                 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)
예제 #40
0
def installLocale(dest_path, installed_path):
    po_dir = os.path.join(installed_path, "po")
    for path, names, filenames in os.walk(po_dir):
        for f in filenames:
            if f.endswith(".po"):
                lang = f[:-3]
                src = os.path.join(path, f)
                locale = os.path.join(dest_path, lang, "LC_MESSAGES")
                dest = os.path.join(locale, "cinnamon-installer.mo")
                if not os.path.exists(locale):
                    os.makedirs(locale)
                if not os.path.exists(dest):
                    print("Compiling %s" % src)
                    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)
                        make(src, dest)
예제 #41
0
def installLocale(dest_path, installed_path):
    po_dir = os.path.join(installed_path, "po")
    for path, names, filenames in os.walk(po_dir):
        for f in filenames:
            if f.endswith(".po"):
                lang = f[:-3]
                src = os.path.join(path, f)
                locale = os.path.join(dest_path, lang, "LC_MESSAGES")
                dest = os.path.join(locale, "cinnamon-installer.mo")
                if not os.path.exists(locale):
                    os.makedirs(locale)
                if not os.path.exists(dest):
                    print("Compiling %s" % src)
                    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)
                        make(src, dest)
예제 #42
0
 def run(self):
     po_dir = os.path.join(os.path.dirname(os.curdir), "src/po")
     for path, names, filenames in os.walk(po_dir):
         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, "librarian.mo")
                 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)
예제 #43
0
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"))
예제 #44
0
파일: setup.py 프로젝트: s0undt3ch/Deluge
 def run(self):
     po_dir = os.path.join(os.path.dirname(__file__), 'deluge/i18n/')
     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(self.build_lib, 'deluge', 'i18n', 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):
                     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)
예제 #45
0
 def run(self):
     po_dir = os.path.join(os.path.dirname(os.curdir), 'OWDTestToolkit/locale')
     for path, names, filenames in os.walk(po_dir):
         for f in filenames:
             if f.endswith('.po'):
                 lang = path.split('/')[-1]
                 src = os.path.join(path, f)
                 dist_dir = site.getsitepackages()[0]
                 dest_path = os.path.join(dist_dir, 'OWDTestToolkit/locale', lang, 'LC_MESSAGES')
                 dest = os.path.join(dest_path, 'default.mo')
                 if not os.path.exists(dest_path):
                     os.makedirs(dest_path)
                 if not os.path.exists(dest):
                     print '*** Compiling {}'.format(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 {}'.format(src)
                         msgfmt.make(src, dest)
예제 #46
0
 def run(self):
     po_dir = os.path.join(self.trans_base, self.trans_dir)
     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(self.trans_dist, lang,
                                          'LC_MESSAGES')
                 dest = os.path.join(dest_path, self.trans_domain)
                 if not os.path.exists(dest_path):
                     os.makedirs(dest_path)
                 if not os.path.exists(dest):
                     print 'Compiling locale %s to %s' % (src, dest)
                     msgfmt.make(src, dest)
                 else:
                     src_mtime = os.stat(src)[8]
                     dest_mtime = os.stat(dest)[8]
                     if src_mtime > dest_mtime:
                         print 'Compiling locale %s to %s' % (src, dest)
                         msgfmt.make(src, dest)
예제 #47
0
 def run(self):
     po_dir = os.path.join(os.path.dirname(os.curdir), 'src/po')
     for path, names, filenames in os.walk(po_dir):
         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, 'librarian.mo')
                 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)
예제 #48
0
 def run(self):
     po_dir = os.path.join(os.path.dirname(__file__), 'deluge/i18n/')
     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(self.build_lib, 'deluge', 'i18n', 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):
                     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)
예제 #49
0
파일: setup.py 프로젝트: vguerci/Deluge.app
    def run(self):
        po_dir = os.path.join(os.path.dirname(__file__), "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/data/share/applications/deluge.desktop.in"
            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(self.build_lib, "deluge", "i18n", 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")
예제 #50
0
 def run(self):
     po_dir = os.path.join(os.path.dirname(os.curdir),
                           'OWDTestToolkit/locale')
     for path, names, filenames in os.walk(po_dir):
         for f in filenames:
             if f.endswith('.po'):
                 lang = path.split('/')[-1]
                 src = os.path.join(path, f)
                 dist_dir = site.getsitepackages()[0]
                 dest_path = os.path.join(dist_dir, 'OWDTestToolkit/locale',
                                          lang, 'LC_MESSAGES')
                 dest = os.path.join(dest_path, 'default.mo')
                 if not os.path.exists(dest_path):
                     os.makedirs(dest_path)
                 if not os.path.exists(dest):
                     print '*** Compiling {}'.format(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 {}'.format(src)
                         msgfmt.make(src, dest)
예제 #51
0
파일: setup.py 프로젝트: M7S/dockbarx
 def run(self):
     po_dict = {
                 "dockbarx": os.path.join(os.path.dirname(os.curdir), "po"),
                 "dockbarx-themes": os.path.join(os.path.dirname(os.curdir), "po-themes")
               }
     for (mo_file, po_dir) in po_dict.items():
         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", lang, "LC_MESSAGES")
                     dest = os.path.join(dest_path, "%s.mo"%mo_file)
                     if not os.path.exists(dest_path):
                         os.makedirs(dest_path)
                     if not os.path.exists(dest):
                         print "Compiling %s for %s" % (src, mo_file)
                         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 for %s" % (src, mo_file)
                             msgfmt.make(src, dest)
예제 #52
0
 def run(self):
     po_dict = {
                 'dockbarx': os.path.join(os.path.dirname(os.curdir), 'po'),
                 'dockbarx-themes': os.path.join(os.path.dirname(os.curdir), 'po-themes')
               }
     for (mo_file, po_dir) in po_dict.items():
         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', lang, 'LC_MESSAGES')
                     dest = os.path.join(dest_path, "%s.mo"%mo_file)
                     if not os.path.exists(dest_path):
                         os.makedirs(dest_path)
                     if not os.path.exists(dest):
                         print 'Compiling %s for %s' % (src, mo_file)
                         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 for %s' % (src, mo_file)
                             msgfmt.make(src, dest)
예제 #53
0
DATA_FILES += [('share/man/man1', ['manpages/pychess.1.gz'])]

# Language
pofile = "LC_MESSAGES/pychess"
if sys.platform == "win32":
    argv0_path = os.path.dirname(os.path.abspath(sys.executable))
    sys.path.append(argv0_path + "\\tools\\i18n")
    import msgfmt

for dir in [
        d for d in listdir("lang")
        if d.find(".svn") < 0 and isdir("lang/" + d) and d != "en"
]:
    if sys.platform == "win32":
        file = "lang/%s/%s" % (dir, pofile)
        msgfmt.make(file + ".po", file + ".mo")
    else:
        os.popen("msgfmt lang/%s/%s.po -o lang/%s/%s.mo" %
                 (dir, pofile, dir, pofile))
    DATA_FILES += [("share/locale/" + dir + "/LC_MESSAGES",
                    ["lang/" + dir + "/" + pofile + ".mo"])]

# Packages

PACKAGES = [
    "pychess", "pychess.gfx", "pychess.ic", "pychess.ic.managers",
    "pychess.Players", "pychess.Savers", "pychess.System", "pychess.Utils",
    "pychess.Utils.lutils", "pychess.Variants", "pychess.widgets",
    "pychess.widgets.pydock"
]
# Setup
예제 #54
0
import glob
import os
import subprocess
import sys

LOCALE_MAPPING = {
    "cs": "cs_CZ",
    "de_DE": "de_DE",
    "el": "el_GR",
    "es_ES": "es_ES",
    "fr": "fr_FR",
    "it": "it_IT",
    "pl": "pl_PL",
    "ro": "ro_RO",
    "ru": "ru_RU",
    "tr": "tr_TR",
    "zh_Hans_CN": "zh_CN"
}

sys.path.append(os.path.join(os.path.dirname(sys.executable), "Tools", "i18n"))

from msgfmt import make

subprocess.run(["powershell.exe", "zanata-cli/bin/zanata-cli", "pull", "-B"])

for filename in glob.glob("../src/locale/*.mo"):
    os.remove(filename)

for name, name2 in LOCALE_MAPPING.items():
    make(f"po/{name}.po", f"../src/locale/{name2}.mo")
예제 #55
0
def makeMO(poPath):
    moPath = poPath[0:poPath.rfind('.')] + '.mo'
    msgfmt.make(poPath, moPath)
예제 #56
0
os.environ['GDAL_DATA'] = gdal_path

egg_path = os.path.join(dll_path, 'py')
sys.path.append(egg_path)
libs = glob.glob(os.path.join(egg_path, '*.egg'))
for lib in libs:
    sys.path.append(lib)
__all__.append('ogr')

# Code for translating task messages.
locale.setlocale(locale.LC_ALL, '')
loc = locale.getlocale()[0].lower()[0:2]
try:
    sys.path.append(os.path.join(os.path.dirname(sys.executable), "tools", "i18n"))
    import msgfmt
    mo_filename = os.path.join(os.path.dirname(__file__), "locale", "LC_MESSAGES", "messages_%s.mo" % loc)
    po_filename = os.path.join(os.path.dirname(__file__), "locale", "LC_MESSAGES", "messages_%s.po" % loc)
    if not os.path.exists(mo_filename) and os.path.exists(po_filename):
        msgfmt.make(po_filename, mo_filename)
    trans = gettext.GNUTranslations(open(mo_filename, "rb"))
except (IOError, ImportError):
    trans = gettext.NullTranslations()

# This has changed in Python 3.x
if sys.version_info[0] < 3:
    trans.install(unicode=True)
    _ = trans.ugettext
else:
    trans.install()
    _ = trans.gettext