[Libguestfs] [PATCH 1/3] po: fix broken message extraction

Pino Toscano ptoscano at redhat.com
Thu Dec 5 15:30:04 UTC 2013


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




More information about the Libguestfs mailing list