diff --git a/backends.py b/backends.py index fe92a46d9..11083c246 100644 --- a/backends.py +++ b/backends.py @@ -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) diff --git a/interpreter.py b/interpreter.py index 28afac8fc..dcf733928 100644 --- a/interpreter.py +++ b/interpreter.py @@ -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: diff --git a/test cases/frameworks/6 gettext/po/intltest.pot b/test cases/frameworks/6 gettext/po/intltest.pot new file mode 100644 index 000000000..340f87b51 --- /dev/null +++ b/test cases/frameworks/6 gettext/po/intltest.pot @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 ""