Scons: update_po target part four: lyx.po

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17503 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2007-03-22 03:15:58 +00:00
parent 1385059003
commit b92cef16ee
2 changed files with 29 additions and 11 deletions

View File

@ -718,6 +718,7 @@ else:
env['MSGFMT'] = conf.CheckCommand('msgfmt')
env['MSGMERGE'] = conf.CheckCommand('msgmerge')
env['XGETTEXT'] = conf.CheckCommand('xgettext')
env['MSGUNIQ'] = conf.CheckCommand('msguniq')
# if under windows, check the nsis compiler
if platform_name == 'win32':
@ -1989,7 +1990,7 @@ if update_po:
if env.has_key('languages'):
languages = env.make_list(env['lanauges'])
# whether or not update po files
if not env['XGETTEXT'] or not env['MSGMERGE']:
if not env['XGETTEXT'] or not env['MSGMERGE'] or not env['MSGUNIQ']:
print 'xgettext or msgmerge does not exist. Can not merge po files'
Exit(1)
# create a builder that generate
@ -2017,19 +2018,26 @@ if update_po:
if not languages or country in languages:
# merge po files
env.msgmerge(f, '$BUILDDIR/common/lyx.pot')
# build language_l10n.pot
# build language_l10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot
# and combine them to lyx.po
env['BUILDERS']['language_l10n'] = Builder(action=utils.env_language_l10n)
tar1 = env.language_l10n('$BUILDDIR/common/language_l10n.pot', '$TOP_SRCDIR/lib/languages')
env['BUILDERS']['qt4_l10n'] = Builder(action=utils.env_qt4_l10n)
tar2 = env.qt4_l10n('$BUILDDIR/common/qt4_l10n.pot',
['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files])
env['BUILDERS']['layouts_l10n'] = Builder(action=utils.env_layouts_l10n)
tar3 = env.layouts_l10n('$BUILDDIR/common/layouts_l10n.pot',
['$TOP_SRCDIR/lib/layouts/%s' % x for x in lib_layouts_files])
env['BUILDERS']['ui_l10n'] = Builder(action=utils.env_ui_l10n)
tar4 = env.ui_l10n('$BUILDDIR/common/ui_l10n.pot',
env['BUILDERS']['cat'] = Builder(action=utils.env_cat)
env['BUILDERS']['lyx_po'] = Builder(action='$MSGUNIQ -o $TARGET $SOURCE')
lyx_po = env.lyx_po('$BUILDDIR/common/lyx.po',
env.cat('$BUILDDIR/common/all.po',
[env.language_l10n('$BUILDDIR/common/language_l10n.pot', '$TOP_SRCDIR/lib/languages'),
env.qt4_l10n('$BUILDDIR/common/qt4_l10n.pot',
['$TOP_SRCDIR/src/frontends/qt4/ui/%s' % x for x in src_frontends_qt4_ui_files]),
env.layouts_l10n('$BUILDDIR/common/layouts_l10n.pot',
['$TOP_SRCDIR/lib/layouts/%s' % x for x in lib_layouts_files]),
env.ui_l10n('$BUILDDIR/common/ui_l10n.pot',
['$TOP_SRCDIR/lib/ui/%s' % x for x in lib_ui_files])
Alias('update_po', [tar1, tar2, tar3, tar4])
])
)
Alias('update_po', lyx_po)
if build_po:

View File

@ -205,7 +205,7 @@ def env_layouts_l10n(target, source, env):
def env_ui_l10n(target, source, env):
'''Generate pot file from lib/ui/*.layout and *.inc'''
'''Generate pot file from lib/ui/*'''
output = open(env.File(target[0]).abspath, 'w')
Submenu = re.compile(r'^[^#]*Submenu\s+"([^"]*)"')
Toolbar = re.compile(r'^[^#]*Toolbar\s+"[^"]+"\s+"([^"]*)"')
@ -231,6 +231,16 @@ def env_ui_l10n(target, source, env):
output.close()
def env_cat(target, source, env):
'''Cat source > target. Avoid pipe to increase portability'''
output = open(env.File(target[0]).abspath, 'w')
for src in source:
input = open(env.File(src).abspath)
output.write(input.read())
input.close()
output.close()
def createResFromIcon(env, icon_file, rc_file):
''' create a rc file with icon, and return res file (windows only) '''
if os.name == 'nt':