On Thu, Dec 05, 2013 at 04:30:04PM +0100, Pino Toscano wrote:
Extracting separately the pot for the various languages and then
creating manually the global pot (by manually joining the above ones
after having stripped their headers) is wrong, since other than being
an hack it can create an invalid pot when the same message appears in
sources written in different languages.
Instead, a cleaner and safer solution is to first let ocaml-gettext
(if available) extract the messages for the ml files, and then use
xgettext to extract the messages for the other languages, joining the
new messages to the existing (or not) pot file.
---
po/Makefile.am | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/po/Makefile.am b/po/Makefile.am
index e2bfe45..b0a8038 100644
--- a/po/Makefile.am
+++ b/po/Makefile.am
@@ -66,24 +66,14 @@ XGETTEXT_ARGS = \
--directory=$(top_srcdir)
$(DOMAIN).pot: Makefile $(POTFILES) $(POTFILES-pl) $(POTFILES-ml)
- rm -f $@-t $@-pl $@-ml
- $(XGETTEXT) -o $@-t $(XGETTEXT_ARGS) \
- --files-from=$(abs_srcdir)/POTFILES
- $(XGETTEXT) -o $@-pl $(XGETTEXT_ARGS) --language=Perl \
- --files-from=$(abs_srcdir)/POTFILES-pl
-# Don't trust msgcat since it will definitely screw up. Instead, chop
-# the head from the second file and append it to the first.
- echo >> $@-t
- awk '/^#:/{i++}i{print}' < $@-pl >> $@-t
- rm $@-pl
+ rm -f $@-t
if HAVE_OCAML_GETTEXT
- $(OCAML_GETTEXT) --action extract --extract-pot $@-ml $(POTFILES_ML)
-# Don't trust msgcat since it will definitely screw up. Instead, chop
-# the head from the second file and append it to the first.
- echo >> $@-t
- awk '/^#:/{i++}i{print}' < $@-ml >> $@-t
- rm $@-ml
+ $(OCAML_GETTEXT) --action extract --extract-pot $@-t $(POTFILES_ML)
endif
+ $(XGETTEXT) -j -o $@-t $(XGETTEXT_ARGS) \
+ --files-from=$(abs_srcdir)/POTFILES
+ $(XGETTEXT) -j -o $@-t $(XGETTEXT_ARGS) --language=Perl \
+ --files-from=$(abs_srcdir)/POTFILES-pl
mv $@-t $@
%.po: $(DOMAIN).pot
--
1.8.3.1
ACK.
This appears to be OK, and the results look sane:
$ ll po/libguestfs.pot*
-rw-rw-r--. 1 rjones rjones 180001 Dec 5 15:52 po/libguestfs.pot
-rw-rw-r--. 1 rjones rjones 178207 Dec 5 15:40 po/libguestfs.pot-backup
and I also checked the pot file (which is basically impossible) but it
doesn't look as if messages are being dropped.
Thanks, I'm going to push 1/3 and 3/3 for now.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org