def update_MUI_po(self): ''' update PO file for translating it ''' py_list_path = 'py_list.txt' msgmerge_flags = '--backup=off --sort-output --no-fuzzy-matching --update' xrc_string_path = join(CUR_DIR, 'xrc_string.py') self.generate_xrc_translate_string(xrc_string_path) self.generate_py_list(py_list_path, [ROOT_DIR, SRC_DIR], [xrc_string_path]) env = os.environ.copy() if sys.platform == 'win32': env['PATH'] += os.pathsep + self.gettext_dir env['PATH'] += os.pathsep + self.libiconv2_dir subprocess.check_call('xgettext -o "%s" --files-from=%s' % (join(LANG_DIR, 'base.po'), py_list_path), env=env, shell=True) subprocess.check_call('msgmerge %s "%s" "%s"' % (msgmerge_flags, get_lang_path(LANG_DIR, 'ENU', ext='.po'), join(LANG_DIR, 'base.po')), env=env, shell=True) subprocess.check_call('msgmerge %s "%s" "%s"' % (msgmerge_flags, get_lang_path(LANG_DIR, 'CHT', ext='.po'), join(LANG_DIR, 'base.po')), env=env, shell=True) os.remove(py_list_path) os.remove(xrc_string_path)
def update_MUI_mo(self): ''' convert .po(TEXT file) to .mo(Binary file) ''' msgmerge_output_flags = '--output-file' env = os.environ.copy() if sys.platform == 'win32': env['PATH'] += os.pathsep + self.gettext_dir env['PATH'] += os.pathsep + self.libiconv2_dir subprocess.check_call('msgfmt %s "%s" "%s"' % (msgmerge_output_flags, get_lang_path(LANG_DIR, 'CHT', ext='.mo'), get_lang_path(LANG_DIR, 'CHT', ext='.po')), env=env, shell=True) subprocess.check_call('msgfmt %s "%s" "%s"' % (msgmerge_output_flags, get_lang_path(LANG_DIR, 'ENU', ext='.mo'), get_lang_path(LANG_DIR, 'ENU', ext='.po')), env=env, shell=True)