SCons recipe: invoke po4a tools directly.

This commit is contained in:
Sergey Popov 2008-05-31 20:08:31 +00:00
parent d36b4a50ee
commit 7bc432775d
3 changed files with 31 additions and 30 deletions

View file

@ -65,10 +65,8 @@ if "pot-update" in COMMAND_LINE_TARGETS:
env.Alias("pot-update", "../translations")
if "update-po" in COMMAND_LINE_TARGETS or "pot-update" in COMMAND_LINE_TARGETS:
if "update-po" in COMMAND_LINE_TARGETS or "pot-update" in COMMAND_LINE_TARGETS or "update-po4a" in COMMAND_LINE_TARGETS:
for domain in textdomains:
if ("update-po4a" in COMMAND_LINE_TARGETS or "pot-update" in COMMAND_LINE_TARGETS) and domain in po4a_domains:
continue
for lingua in linguas:
update_po = env.MsgInitMerge(
os.path.join(domain, lingua),
@ -87,36 +85,27 @@ if "update-po" in COMMAND_LINE_TARGETS or "pot-update" in COMMAND_LINE_TARGETS:
# Manual and man pages translation
#
def parse_po4a_cfg(cfg_file):
cfg_file = cfg_file.replace("\\\n", "")
po4a_cfg_re = re.compile(r"^\[(.*)\] (.*)$", re.MULTILINE)
opts = dict(po4a_cfg_re.findall(cfg_file))
return opts
if "update-po4a" in COMMAND_LINE_TARGETS or "pot-update" in COMMAND_LINE_TARGETS:
linguas = parse_po4a_cfg(File("wesnoth-manual/wesnoth-manual.cfg").get_contents())["po4a_langs"].split()
po4a_targets = ["wesnoth-manual/wesnoth-manual.pot"]
env.Po4aGettextize("wesnoth-manual/wesnoth-manual.pot", "../doc/manual/manual.en.xml", PO4A_FORMAT = "docbook")
for lingua in linguas:
po4a_targets.append(os.path.join("wesnoth-manual", lingua + ".po"))
env.Precious(po4a_targets)
NoClean(po4a_targets)
for lingua in linguas:
po4a_targets.append(os.path.join("../doc/manual", "manual." + lingua + ".xml"))
env.AlwaysBuild(env.Command(po4a_targets, "../doc/manual/manual.en.xml",
"""po4a --no-backups --copyright-holder "Wesnoth Development Team" wesnoth-manual.cfg""", chdir = "po/wesnoth-manual"))
env.Alias("update-po4a", "wesnoth-manual/wesnoth-manual.pot")
env.Po4aTranslate("../doc/manual/manual." + lingua + ".xml",
["../doc/manual/manual.en.xml", join("wesnoth-manual", lingua + ".po")],
PO4A_CHARSET = "utf8", PO4A_FORMAT = "docbook")
Alias("update-po4a", Alias("manual"))
linguas = parse_po4a_cfg(File("wesnoth-manpages/wesnoth-manpages.cfg").get_contents())["po4a_langs"].split()
po4a_targets = ["wesnoth-manpages/wesnoth-manpages.pot"]
manpages = Split("wesnoth.6 wesnoth_editor.6 wesnothd.6")
charsets = { "ar":"utf8", "bg":"cp1251", "ca_ES@valencia":"iso-8859-15", "cs":"iso-8859-2", "el":"iso-8859-7",
"he":"iso-8859-8", "hr":"utf8", "hu":"iso-8859-2", "ja":"euc-jp", "ko":"euc-kr", "lt":"iso-8859-13", "pl":"iso-8859-2",
"ro":"iso-8859-2", "ru":"iso-8859-5", "sk":"iso-8859-2", "sl":"iso-8859-2", "sr":"utf8", "sr@latin":"utf8",
"tr":"iso-8859-9", "zh_CN":"gb2312" }
env.Po4aGettextize("wesnoth-manpages/wesnoth-manpages.pot",
[join("../doc/man", man) for man in manpages], PO4A_FORMAT = "man")
for lingua in linguas:
po4a_targets.append(os.path.join("wesnoth-manpages", lingua + ".po"))
env.Precious(po4a_targets)
NoClean(po4a_targets)
for lingua in linguas:
po4a_targets += [ os.path.join("../doc/man", lingua, x) for x in ["wesnoth.6", "wesnoth_editor.6", "wesnothd.6"] ]
env.AlwaysBuild(env.Command(po4a_targets, [ os.path.join("../doc/man", x) for x in ["wesnoth.6", "wesnoth_editor.6", "wesnothd.6"] ],
"""po4a --no-backups --copyright-holder "Wesnoth Development Team" wesnoth-manpages.cfg""", chdir = "po/wesnoth-manpages"))
env.Alias("update-po4a", "wesnoth-manpages/wesnoth-manpages.pot")
for man in manpages:
env.Po4aTranslate(join("../doc/man", lingua, man),
[join("../doc/man", man), join("wesnoth-manpages", lingua + ".po")],
PO4A_CHARSET = charsets.get(lingua, "iso-8859-1"), PO4A_FORMAT = "man")
Alias("update-po4a", "../doc/man")
#
# If we have the right tool in place, create targets to invoke msgfmt to

View file

@ -44,3 +44,15 @@ def generate(env):
return env.MsgInit(target, source)
from SCons.Script.SConscript import SConsEnvironment
SConsEnvironment.MsgInitMerge = MsgInitMerge
env["PO4A_GETTEXTIZE"] = WhereIs("po4a-gettextize")
po4a_gettextize = Builder(
action = "$PO4A_GETTEXTIZE -f $PO4A_FORMAT ${''.join([' -m ' + str(source) for source in SOURCES])} -p $TARGET",
)
env["BUILDERS"]["Po4aGettextize"] = po4a_gettextize
env["PO4A_TRANSLATE"] = WhereIs("po4a-translate")
po4a_translate = Builder(
action = "$PO4A_TRANSLATE -f $PO4A_FORMAT -L $PO4A_CHARSET -m ${SOURCES[0]} -p ${SOURCES[1]} -l $TARGET"
)
env["BUILDERS"]["Po4aTranslate"] = po4a_translate

View file

@ -290,7 +290,7 @@ if env["svnrev"] != "" and env["svnrev"] != "exported":
sources = []
if "TAGS" in COMMAND_LINE_TARGETS:
EnsureSConsVersion(0, 98)
sources = [ Glob(os.path.join(dir, pattern), ondisk=False) for dir in ["", "*", "*/*"] for pattern in ["*.cpp", "*.hpp"] ]
sources = [ Glob(os.path.join(dir, pattern)) for dir in ["", "*", "*/*"] for pattern in ["*.cpp", "*.hpp"] ]
Export("sources")