Can generate pot files on command.

pull/15/head
Jussi Pakkanen 11 years ago
parent 3c3e580aea
commit 8523bd6ba7
  1. 15
      backends.py
  2. 2
      interpreter.py
  3. 22
      test cases/frameworks/6 gettext/po/intltest.pot

@ -312,6 +312,9 @@ class NinjaBackend(Backend):
self.generate_rules(outfile)
outfile.write('# Build rules for targets\n\n')
[self.generate_target(t, outfile) for t in self.build.get_targets().values()]
if len(self.build.pot) > 0:
outfile.write('# Build rules for localisation.\n\n')
self.generate_po(outfile)
outfile.write('# Test rules\n\n')
self.generate_tests(outfile)
outfile.write('# Install rules\n\n')
@ -326,6 +329,16 @@ class NinjaBackend(Backend):
outfile.close()
os.replace(tempfilename, outfilename)
def generate_po(self, outfile):
for p in self.build.pot:
(packagename, languages, subdir) = p
input_file = os.path.join(subdir, 'POTFILES')
elem = NinjaBuildElement('pot', 'GEN_POT', [])
elem.add_item('OUTFILE', packagename + '.pot')
elem.add_item('FILELIST', os.path.join(self.environment.get_source_dir(), input_file))
elem.add_item('OUTDIR', os.path.join(self.environment.get_source_dir(), subdir))
elem.write(outfile)
def generate_coverage_rules(self, outfile):
(gcovr_exe, lcov_exe, genhtml_exe) = environment.find_coverage_tools()
added_rule = False
@ -510,7 +523,7 @@ class NinjaBackend(Backend):
def generate_gettext_rules(self, outfile):
rule = 'rule GEN_POT\n'
command = " command = xgettext -p '$OUTDIR' -D '%s' -k_ -o '$OUTFILE'\n" % \
command = " command = xgettext -p $OUTDIR -f $FILELIST -D '%s' -k_ -o $OUTFILE\n" % \
self.environment.get_source_dir()
outfile.write(rule)
outfile.write(command)

@ -994,7 +994,7 @@ class Interpreter():
# TODO: check that elements are strings
if len(self.build.pot) > 0:
raise InterpreterException('More than one gettext definitions currently not supported.')
self.build.pot.append((packagename, languages))
self.build.pot.append((packagename, languages, self.subdir))
def func_configuration_data(self, node, args, kwargs):
if len(args) != 0:

@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-09-12 18:53+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/intlmain.c:15
msgid "International greeting."
msgstr ""
Loading…
Cancel
Save