コード例 #1
0
ファイル: setup.py プロジェクト: pakesson/rednotebook
def build_mo_files():
    '''
    Little script that compiles all available po files into mo files
    '''

    po_dir = 'po'

    if not os.path.exists(i18n_dir):
        os.mkdir(i18n_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(i18n_dir, lang)
        mo_dir = os.path.join(lang_dir, 'LC_MESSAGES')
        mo_file = os.path.join(mo_dir, 'rednotebook.mo')
        #cmd = ['msgfmt', '--output-file=%s' % mo_file, po_file]
        #print 'cmd', cmd

        for dir in [lang_dir, mo_dir]:
            if not os.path.exists(dir):
                os.mkdir(dir)

        #call(cmd)
        print 'Compiling %s to %s' % (po_file, mo_file)
        msgfmt.make(po_file, mo_file)
コード例 #2
0
ファイル: setup.py プロジェクト: pakesson/rednotebook
def build_mo_files():
    '''
    Little script that compiles all available po files into mo files
    '''

    po_dir = 'po'

    if not os.path.exists(i18n_dir):
        os.mkdir(i18n_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(i18n_dir, lang)
        mo_dir = os.path.join(lang_dir, 'LC_MESSAGES')
        mo_file = os.path.join(mo_dir, 'rednotebook.mo')
        #cmd = ['msgfmt', '--output-file=%s' % mo_file, po_file]
        #print 'cmd', cmd

        for dir in [lang_dir, mo_dir]:
            if not os.path.exists(dir):
                os.mkdir(dir)

        #call(cmd)
        print 'Compiling %s to %s' % (po_file, mo_file)
        msgfmt.make(po_file, mo_file)
コード例 #3
0
ファイル: setup.py プロジェクト: jendrikseipp/rednotebook
def build_translation_files(po_dir, locale_dir):
    assert os.path.isdir(po_dir), po_dir
    for path, names, filenames in os.walk(po_dir):
        for f in filenames:
            if f.endswith('.po'):
                lang = os.path.splitext(f)[0]
                src = os.path.join(path, f)
                dest = os.path.join(locale_dir, lang, 'LC_MESSAGES', 'rednotebook.mo')
                dest_dir = os.path.dirname(dest)
                if not os.path.exists(dest_dir):
                    os.makedirs(dest_dir)
                # Recompile only if compiled version is outdated.
                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)
コード例 #4
0
def build_translation_files(po_dir, locale_dir):
    assert os.path.isdir(po_dir), po_dir
    for path, names, filenames in os.walk(po_dir):
        for f in filenames:
            if f.endswith('.po'):
                lang = os.path.splitext(f)[0]
                src = os.path.join(path, f)
                dest = os.path.join(locale_dir, lang, 'LC_MESSAGES',
                                    'rednotebook.mo')
                dest_dir = os.path.dirname(dest)
                if not os.path.exists(dest_dir):
                    os.makedirs(dest_dir)
                # Recompile only if compiled version is outdated.
                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)