[PATCH 2/3 v2] Fix pre-processing of files for xgettext (#1005644)
David Shea
dshea at redhat.com
Tue Sep 10 19:34:40 UTC 2013
This combines the Rules-glade and Rules-liveinst into one file and
modifies the rules so 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 +++
po/POTFILES.in | 68 +++++++++++++++++++++++++++++++------------------------
po/Rules-extract | 43 +++++++++++++++++++++++++++++++++++
po/Rules-glade | 11 ---------
po/Rules-liveinst | 17 --------------
5 files changed, 84 insertions(+), 58 deletions(-)
create mode 100644 po/Rules-extract
delete mode 100644 po/Rules-glade
delete mode 100644 po/Rules-liveinst
diff --git a/.gitignore b/.gitignore
index c076307..e888426 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,6 +66,7 @@ po/quot.sed
po/remove-potcdate.sed
po/remove-potcdate.sin
po/stamp-po
+po/tmp
py-compile
stamp-h1
tags
@@ -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/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-extract b/po/Rules-extract
new file mode 100644
index 0000000..dd3e242
--- /dev/null
+++ b/po/Rules-extract
@@ -0,0 +1,43 @@
+# Handle files that xgettext can't handle automatically
+
+# intltool-extract is 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.
+#
+# All output files need to be in $srcdir for gettext to be able to find them.
+
+%.glade.h: %.glade
+ @intltool-extract -q --type=gettext/glade -l $< && \
+ mv tmp/$$(basename $@) $@
+
+%.desktop.in.h: %.desktop.in
+ @intltool-extract -q --type=gettext/keys -l $< && \
+ mv tmp/$$(basename $@) $@
+
+%liveinst.h: %liveinst
+ @intltool-extract -q --type=gettext/quoted -l $< && \
+ mv tmp/$$(basename $@) $@
+
+# 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_srcdir)/anaconda.po $(top_srcdir)/data/liveinst/gnome/fedora-welcome.po \
+ $(top_srcdir)/data/liveinst/console.apps/liveinst.h
+ find $(top_srcdir) \( -name '*.glade.h' -o -name '*.desktop.in.h' \) \
+ -exec rm -f {} \;
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)
--
1.8.3.1
More information about the anaconda-patches
mailing list