[PATCH 2/3] Fix pre-processing of files for xgettext (#1005644)

David Shea dshea at redhat.com
Tue Sep 10 16:10:14 UTC 2013


This combines the Rules-glade and Rules-liveinst into one file and
modifies the rules that they work with all of our various glade and
liveinst paths. Update POTFILES.in to point to the generated files so
that xgettext doesn't try to process the source files directly.

For files that xgettext can handle but can't autodetect the type,
manually extract strings into a .po file. xgettext can import .po files
into the .pot and knows to leave the file names and line numbers alone.
---
 .gitignore         |  3 +++
 configure.ac       |  1 +
 po/POTFILES.in     | 68 ++++++++++++++++++++++++++++++------------------------
 po/Rules-glade     | 11 ---------
 po/Rules-liveinst  | 17 --------------
 po/tmpl-extract.in | 54 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 96 insertions(+), 58 deletions(-)
 delete mode 100644 po/Rules-glade
 delete mode 100644 po/Rules-liveinst
 create mode 100644 po/tmpl-extract.in

diff --git a/.gitignore b/.gitignore
index c076307..d60c514 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ po/Makefile.in.in
 po/Makevars.template
 po/POTFILES
 po/Rules-quot
+po/Rules-extract
 po/boldquot.sed
 po/en at boldquot.insert-header
 po/en at boldquot.header
@@ -85,3 +86,5 @@ widgets/doc/html
 widgets/doc/xml
 widgets/gtk-doc.make
 widgets/src/gettext.h
+anaconda.po
+data/liveinst/gnome/fedora-welcome.po
diff --git a/configure.ac b/configure.ac
index 0da79ad..4237506 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,6 +223,7 @@ AC_CONFIG_FILES([Makefile
                  data/icons/hicolor/256x256/apps/Makefile
                  data/systemd/Makefile
                  po/Makefile.in
+                 po/Rules-extract:po/tmpl-extract.in
                  scripts/Makefile
                  pyanaconda/Makefile
                  pyanaconda/isys/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4820137..90ce6e4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@
 # Copyright (C) 2009  Red Hat, Inc.
 
 # Main anaconda source files
-anaconda
 pyanaconda/bootloader.py
 pyanaconda/constants.py
 pyanaconda/image.py
@@ -82,32 +81,6 @@ pyanaconda/ui/gui/spokes/lib/refresh.py
 pyanaconda/ui/gui/spokes/lib/resize.py
 pyanaconda/ui/gui/spokes/lib/summary.py
 
-# Interface files.
-pyanaconda/ui/gui/spokes/advanced_user.glade
-pyanaconda/ui/gui/spokes/datetime_spoke.glade
-pyanaconda/ui/gui/spokes/filter.glade
-pyanaconda/ui/gui/spokes/network.glade
-pyanaconda/ui/gui/spokes/software.glade
-pyanaconda/ui/gui/spokes/storage.glade
-pyanaconda/ui/gui/spokes/keyboard.glade
-pyanaconda/ui/gui/spokes/langsupport.glade
-pyanaconda/ui/gui/spokes/password.glade
-pyanaconda/ui/gui/spokes/source.glade
-pyanaconda/ui/gui/spokes/welcome.glade
-pyanaconda/ui/gui/spokes/user.glade
-pyanaconda/ui/gui/spokes/custom.glade
-pyanaconda/ui/gui/spokes/advstorage/fcoe.glade
-pyanaconda/ui/gui/spokes/advstorage/iscsi.glade
-pyanaconda/ui/gui/spokes/lib/cart.glade
-pyanaconda/ui/gui/spokes/lib/detailederror.glade
-pyanaconda/ui/gui/spokes/lib/passphrase.glade
-pyanaconda/ui/gui/spokes/lib/refresh.glade
-pyanaconda/ui/gui/spokes/lib/resize.glade
-pyanaconda/ui/gui/spokes/lib/summary.glade
-pyanaconda/ui/gui/main.glade
-pyanaconda/ui/gui/hubs/summary.glade
-pyanaconda/ui/gui/hubs/progress.glade
-
 # Custom widgets.
 widgets/src/BaseWindow.c
 widgets/src/DiskOverview.c
@@ -122,10 +95,45 @@ widgets/src/glade-adaptor.c
 widgets/src/lightbox.c
 widgets/src/tz.c
 
-# welcome screen for GNOME Shell
-data/liveinst/gnome/fedora-welcome
-data/liveinst/gnome/fedora-welcome.desktop.in
+# For file types that gettext doesn't understand, list <filename>.h and
+# use Rules-extract to extract the strings into a C-style header.
+
+# Interface files.
+# gettext doesn't fully support glade3
+pyanaconda/ui/gui/spokes/advanced_user.glade.h
+pyanaconda/ui/gui/spokes/datetime_spoke.glade.h
+pyanaconda/ui/gui/spokes/filter.glade.h
+pyanaconda/ui/gui/spokes/network.glade.h
+pyanaconda/ui/gui/spokes/software.glade.h
+pyanaconda/ui/gui/spokes/storage.glade.h
+pyanaconda/ui/gui/spokes/keyboard.glade.h
+pyanaconda/ui/gui/spokes/langsupport.glade.h
+pyanaconda/ui/gui/spokes/password.glade.h
+pyanaconda/ui/gui/spokes/source.glade.h
+pyanaconda/ui/gui/spokes/welcome.glade.h
+pyanaconda/ui/gui/spokes/user.glade.h
+pyanaconda/ui/gui/spokes/custom.glade.h
+pyanaconda/ui/gui/spokes/advstorage/fcoe.glade.h
+pyanaconda/ui/gui/spokes/advstorage/iscsi.glade.h
+pyanaconda/ui/gui/spokes/lib/cart.glade.h
+pyanaconda/ui/gui/spokes/lib/detailederror.glade.h
+pyanaconda/ui/gui/spokes/lib/passphrase.glade.h
+pyanaconda/ui/gui/spokes/lib/refresh.glade.h
+pyanaconda/ui/gui/spokes/lib/resize.glade.h
+pyanaconda/ui/gui/spokes/lib/summary.glade.h
+pyanaconda/ui/gui/main.glade.h
+pyanaconda/ui/gui/hubs/summary.glade.h
+pyanaconda/ui/gui/hubs/progress.glade.h
 
 # liveinst source files
 data/liveinst/liveinst.desktop.in.h
 data/liveinst/console.apps/liveinst.h
+
+# welcome screen for GNOME Shell
+data/liveinst/gnome/fedora-welcome.desktop.in.h
+
+# These are files that gettext does understand, but that lack an extension
+# for xgettext to detect the language. Use Rules-extract to generate a .po
+# that will be imported into the .pot.
+anaconda.po
+data/liveinst/gnome/fedora-welcome.po
diff --git a/po/Rules-glade b/po/Rules-glade
deleted file mode 100644
index e3d7308..0000000
--- a/po/Rules-glade
+++ /dev/null
@@ -1,11 +0,0 @@
-UI_SRCS = $(wildcard $(top_srcdir)/data/ui/*.glade)
-UI_HDRS = $(UI_SRCS:.glade=.glade.h)
-
-%.glade.h: %.glade
-	@cd $(top_builddir)/data/ui ; \
-	intltool-extract -q --type=gettext/glade -l $$(basename $<) ; \
-	mv tmp/*h . ; \
-	rmdir tmp
-
-mostlyclean-glade:
-	rm -f $(UI_HDRS)
diff --git a/po/Rules-liveinst b/po/Rules-liveinst
deleted file mode 100644
index b933c3b..0000000
--- a/po/Rules-liveinst
+++ /dev/null
@@ -1,17 +0,0 @@
-LIVEINST_SRCS = $(top_srcdir)/data/liveinst/liveinst.desktop.in $(top_srcdir)/data/liveinst/console.apps/liveinst
-LIVEINST_HDRS = $(top_builddir)/data/liveinst/liveinst.desktop.in.h $(top_builddir)/data/liveinst/console.apps/liveinst.h
-
-%.desktop.in.h: %.desktop.in
-	@cd $(top_builddir)/data/liveinst ; \
-	intltool-extract -q --type=gettext/keys -l $$(basename $<) ; \
-	mv tmp/*h . ; \
-	rmdir tmp
-
-%liveinst.h: %liveinst
-	@cd $(top_builddir)/data/liveinst/console.apps ; \
-	intltool-extract -q --type=gettext/quoted -l $$(basename $<) ; \
-	mv tmp/*h . ; \
-	rmdir tmp
-
-mostlyclean-liveinst:
-	rm -f $(LIVEINST_HDRS)
diff --git a/po/tmpl-extract.in b/po/tmpl-extract.in
new file mode 100644
index 0000000..97b3b8c
--- /dev/null
+++ b/po/tmpl-extract.in
@@ -0,0 +1,54 @@
+# Handle files that xgettext can't handle automatically
+
+# Pull in autoconf variables not set by gettext
+abs_top_srcdir = @abs_top_srcdir@
+abs_top_builddir = @abs_top_builddir@
+
+# The intltool-extract invocation looks kind of weird because intltool-extract
+# acts kind of weird. It treats the input file list as relative to what it
+# thinks $srcdir is, which is either the current directory or the value of the
+# undocumented -s parameter. For the output filename, it has two modes:
+# --update, the default, will output files in the same directory as the input
+# file. --local will output files in a tmp/ directory relative to the current
+# working directory.
+#
+# The path names look weird because everything is relative to $srcdir/po
+
+%.glade.h: %.glade
+	@cd $(abs_top_builddir)/$(subdir)/$$(dirname $<) && \
+	intltool-extract -q --type=gettext/glade -l -s $(abs_top_srcdir)/$(subdir)/$$(dirname $<) $$(basename $<) && \
+	mv tmp/$$(basename $@) . && \
+	( rmdir tmp || exit 0 )
+
+%.desktop.in.h: %.desktop.in
+	cd $(abs_top_builddir)/$(subdir)/$$(dirname $<) && \
+	intltool-extract -q --type=gettext/quoted -l -s $(abs_top_srcdir)/$(subdir)/$$(dirname $<) $$(basename $<) && \
+	mv tmp/$$(basename $@) . && \
+	( rmdir tmp || exit 0 )
+
+%liveinst.h: %liveinst
+	cd $(abs_top_builddir)/$(subdir)/$$(dirname $<) && \
+	intltool-extract -q --type=gettext/quoted -l -s $(abs_top_srcdir)/$(subdir)/$$(dirname $<) $$(basename $<) && \
+	mv tmp/$$(basename $@) . && \
+	( rmdir tmp || exit 0 )
+
+# Remove the $top_srcdir prefix from files so that xgettext can search for the file
+# relative to $top_srcdir and get the path name right in the .po
+%anaconda.po: %anaconda
+	@input_file="$<" && \
+	xgettext $(XGETTEXT_OPTIONS) --omit-header --directory=$(top_srcdir) \
+		--language=Python -o $@ $${input_file##$(top_srcdir)/}
+
+# This file is actually JavaScript, but C is close enough
+%fedora-welcome.po: %fedora-welcome
+	@input_file="$<" && \
+	xgettext $(XGETTEXT_OPTIONS) --omit-header --directory=$(top_srcdir) \
+		--language=C -o $@ $${input_file##$(top_srcdir)/}
+
+mostlyclean: mostlyclean-extract
+mostlyclean-extract:
+	rm -f Rules-extract \
+		$(top_builddir)/anaconda.po $(top_builddir)/data/liveinst/gnome/fedora-welcome.po \
+		$(top_builddir)/data/liveinst/console.apps/liveinst.h
+	find $(top_builddir) \( -name '*.glade.h' -o -name '*.desktop.in.h' \) \
+		-exec rm -f {} \;
-- 
1.8.3.1



More information about the anaconda-patches mailing list