[SSSD] [PATCH] Make manual pages translatable

Sumit Bose sbose at redhat.com
Mon Dec 20 16:03:07 UTC 2010


On Mon, Dec 20, 2010 at 04:13:10PM +0100, Sumit Bose wrote:
> On Mon, Dec 20, 2010 at 02:41:18PM +0100, Sumit Bose wrote:
> > On Mon, Dec 20, 2010 at 01:46:49PM +0100, Sumit Bose wrote:
> > > On Fri, Dec 17, 2010 at 09:19:56AM -0500, Stephen Gallagher wrote:
> > > > -----BEGIN PGP SIGNED MESSAGE-----
> > > > Hash: SHA1
> > > > 
> > > > On 12/16/2010 08:51 AM, Jakub Hrozek wrote:
> > > > > On 12/16/2010 01:31 PM, Stephen Gallagher wrote:
> > > > >> On 12/16/2010 06:36 AM, Jakub Hrozek wrote:
> > > > >>> On 12/15/2010 09:48 PM, Stephen Gallagher wrote:
> > > > >>>> Nack. These patches fail to build when configure is run in a directory
> > > > >>>> other than the root of the source checkout (aka a parallel build directory)
> > > > > 
> > > > >>>> See attached build log attempting to build from /dev/shm/test-build.
> > > > > 
> > > > > 
> > > > >>> Thanks, I missed this case in my testing (or rather, I though that make
> > > > >>> distcheck does essentially the same thing).
> > > > > 
> > > > >>> Attached is a patch that always builds the included xml files as the
> > > > >>> real xml sources depend on them.
> > > > > 
> > > > > 
> > > > >> Nack. Running "make translated-manpages" now works in a parallel build
> > > > >> dir, but running "make distcheck" still fails.
> > > > > 
> > > > >> Logs attached.
> > > > > 
> > > > >> distcheck-clean.log shows the attempt to run "make distcheck" from a
> > > > >> perfectly clean checkout with this patch (patch applied, then 'git reset
> > > > >> --hard' to make sure there are no pre-generated translation files)
> > > > > 
> > > > >> distcheck-translated-manpages shows the attempt to run "make distcheck"
> > > > >> from a checkout that was configured and then had "make
> > > > >> translated-manpages" run on it.
> > > > > 
> > > > >> Both of these were run from a parallel build dir.
> > > > > 
> > > > > 
> > > > > 
> > > > > Sumit managed to fix this issue. Attached is my previous patch with his fix.
> > > > 
> > > > 
> > > > 
> > > > Nack. Patch does not update translations when "make distdir" is run.
> > > > This is needed for ensuring that releases always have the latest
> > > > translation data available.
> > > > 
> > > 
> > > The attached patch should fix it, please apply it on top of the other
> > > two.
> > > 
> > > bye,
> > > Sumit
> > 
> > Here is a different version of the patch with the distdir-hook target
> > instead of dist-hook.
> > 
> > bye,
> > Sumit
> > 
> 
> Another new version which can create a missing po directory.
> 
> bye,
> Sumit

Sorry, found another issue. I've added the other two related patches for
your convenience, too.

bye,
Sumit

> 
> > > 
> > > > 
> > > > - -- 
> > > > Stephen Gallagher
> > > > RHCE 804006346421761
> > > > 
> > > > Delivering value year after year.
> > > > Red Hat ranks #1 in value among software vendors.
> > > > http://www.redhat.com/promo/vendor/
> > > > -----BEGIN PGP SIGNATURE-----
> > > > Version: GnuPG v1.4.11 (GNU/Linux)
> > > > Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
> > > > 
> > > > iEYEARECAAYFAk0LcYwACgkQeiVVYja6o6NYYwCfY2J60KRcT5VNHvd88cjAgMjW
> > > > XnMAn0qjI7QBkZsakuYXQ1sIKJarycwb
> > > > =dqh8
> > > > -----END PGP SIGNATURE-----
> > > > _______________________________________________
> > > > sssd-devel mailing list
> > > > sssd-devel at lists.fedorahosted.org
> > > > https://fedorahosted.org/mailman/listinfo/sssd-devel
-------------- next part --------------
From 488e509cd0cbe0633d54ed0c9f2b2b80f92a05a6 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 20 Oct 2010 17:23:11 +0200
Subject: [PATCH 1/3] Make manual pages translatable

Utilizes PO4A to extract translatable strings from Docbook XML sources
and allows translators to submit ordinary .PO files. PO4A then generates
translated Docbook documents that can be used to generate translated end
user documentation.

https://fedorahosted.org/sssd/ticket/297
---
 Makefile.am                |   47 +++---------
 configure.ac               |    5 +-
 contrib/sssd.spec.in       |    2 +
 src/man/Makefile.am        |  179 ++++++++++++++++++++++++++++++++++++++++++++
 src/man/sss_groupdel.8.xml |    2 +-
 5 files changed, 196 insertions(+), 39 deletions(-)
 create mode 100644 src/man/Makefile.am

diff --git a/Makefile.am b/Makefile.am
index c76b1ba..01515ac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 DISTCHECK_CONFIGURE_FLAGS = --with-ldb-lib-dir="$$dc_install_base"/lib/ldb \
                             --with-test-dir=/dev/shm
 
-SUBDIRS = po
+SUBDIRS = po src/man
 
 # Some old versions of automake don't define builddir
 builddir ?= .
@@ -958,41 +958,15 @@ pysss_la_LDFLAGS = \
     -module
 endif
 
-############
-# MANPAGES #
-############
-
-#Special Rules:
-export SGML_CATALOG_FILES
-DOCBOOK_XSLT = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
-XMLLINT_FLAGS = --catalogs --postvalid --nonet --xinclude --noout
-XSLTPROC_FLAGS = --catalogs --xinclude --nonet
-
-man_MANS = \
-    src/man/sss_useradd.8 src/man/sss_userdel.8 src/man/sss_usermod.8 \
-    src/man/sss_groupadd.8 src/man/sss_groupdel.8 src/man/sss_groupmod.8 \
-    src/man/sssd.8 src/man/sssd.conf.5 src/man/sssd-ldap.5 \
-    src/man/sssd-krb5.5 src/man/sssd-ipa.5 src/man/sssd-simple.5 \
-    src/man/sssd_krb5_locator_plugin.8 src/man/sss_groupshow.8 \
-    src/man/pam_sss.8 src/man/sss_obfuscate.8
-EXTRA_DIST += $(man_MANS:%=%.xml) $(wildcard $(srcdir)/src/man/include/*.xml)
-
-SUFFIXES = .1.xml .1 .3.xml .3 .5.xml .5 .8.xml .8
-.1.xml.1:
-	$(XMLLINT) $(XMLLINT_FLAGS) $<
-	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
-
-.3.xml.3:
-	$(XMLLINT) $(XMLLINT_FLAGS) $<
-	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
-
-.5.xml.5:
-	$(XMLLINT) $(XMLLINT_FLAGS) $<
-	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
-
-.8.xml.8:
-	$(XMLLINT) $(XMLLINT_FLAGS) $<
-	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
+################
+# TRANSLATIONS #
+################
+update-po:
+	$(MAKE) -C src/man update-po
+	$(MAKE) -C po update-po
+
+translated-manpages:
+	$(MAKE) -C src/man translate
 
 #######################
 # Installation Extras #
@@ -1084,7 +1058,6 @@ if BUILD_PYTHON_BINDINGS
 	cd $(srcdir)/src/config; $(PYTHON) setup.py build --build-base $(abs_builddir)/src/config clean --all
 endif
 	rm -Rf doc
-	rm -f $(man_MANS)
 
 CLEANFILES = *.X */*.X */*/*.X
 
diff --git a/configure.ac b/configure.ac
index 1ebf2f7..77137fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,6 +142,9 @@ if test x$HAVE_MANPAGES != x; then
     CHECK_STYLESHEET([$SGML_CATALOG_FILES],
                      [http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
                      [Docbook XSL templates])
+    AC_CHECK_PROG([PO4A],[po4a],[po4a],[no])
+    AC_CHECK_PROG([PO4A_TRANSLATE],[po4a-translate],[po4a-translate],[no])
+    AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"])
 fi
 
 if test x$HAVE_PYTHON_BINDINGS != x; then
@@ -184,6 +187,6 @@ AC_DEFINE_UNQUOTED([ABS_BUILD_DIR], ["$abs_build_dir"], [Absolute path to the bu
 AC_SUBST([abs_builddir], $abs_build_dir)
 
 AC_CONFIG_FILES([Makefile contrib/sssd.spec src/examples/rwtab src/doxy.config
-                 src/sysv/systemd/sssd.service po/Makefile.in])
+                 src/sysv/systemd/sssd.service po/Makefile.in src/man/Makefile])
 AC_OUTPUT
 
diff --git a/contrib/sssd.spec.in b/contrib/sssd.spec.in
index d1e505b..0f9ff64 100644
--- a/contrib/sssd.spec.in
+++ b/contrib/sssd.spec.in
@@ -73,6 +73,7 @@ BuildRequires: bind-utils
 BuildRequires: keyutils-libs-devel
 BuildRequires: libnl-devel
 BuildRequires: nscd
+BuildRequires: po4a
 
 %description
 Provides a set of daemons to manage access to remote directories and
@@ -118,6 +119,7 @@ use with ldap_default_authtok_type = obfuscated_password.
     --disable-rpath
 
 make %{?_smp_mflags}
+make translated-manpages
 
 %check
 export CK_TIMEOUT_MULTIPLIER=10
diff --git a/src/man/Makefile.am b/src/man/Makefile.am
new file mode 100644
index 0000000..f66babe
--- /dev/null
+++ b/src/man/Makefile.am
@@ -0,0 +1,179 @@
+# The following variable is dependent on placement of this file
+top_builddir = ../..
+
+############
+# MANPAGES #
+############
+
+#Special Rules:
+export SGML_CATALOG_FILES
+DOCBOOK_XSLT = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
+XMLLINT_FLAGS = --catalogs --postvalid --nonet --xinclude --noout
+XSLTPROC_FLAGS = --catalogs --xinclude --nonet
+
+man_MANS = \
+    sss_useradd.8 sss_userdel.8 sss_usermod.8 \
+    sss_groupadd.8 sss_groupdel.8 sss_groupmod.8 \
+    sssd.8 sssd.conf.5 sssd-ldap.5 \
+    sssd-krb5.5 sssd-ipa.5 sssd-simple.5 \
+    sssd_krb5_locator_plugin.8 sss_groupshow.8 \
+    pam_sss.8 sss_obfuscate.8
+EXTRA_DIST = $(man_MANS:%=%.xml) $(wildcard $(srcdir)/include/*.xml)
+
+SUFFIXES = .1.xml .1 .3.xml .3 .5.xml .5 .8.xml .8
+.1.xml.1:
+	$(XMLLINT) $(XMLLINT_FLAGS) $<
+	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
+
+.3.xml.3:
+	$(XMLLINT) $(XMLLINT_FLAGS) $<
+	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
+
+.5.xml.5:
+	$(XMLLINT) $(XMLLINT_FLAGS) $<
+	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
+
+.8.xml.8:
+	$(XMLLINT) $(XMLLINT_FLAGS) $<
+	$(XSLTPROC) -o $@  $(XSLTPROC_FLAGS) $(DOCBOOK_XSLT) $<
+
+########################
+# MANPAGE TRANSLATIONS #
+########################
+
+PO4A=@PO4A@
+PO4A_TRANSLATE=@PO4A_TRANSLATE@
+SED=@SED@
+
+PACKAGE_DOC=sssd-docs
+
+POTFILE=$(srcdir)/po/$(PACKAGE_DOC).pot
+PO4A_CONFIG=$(builddir)/po/po4a.cfg
+LINGUAS=$(srcdir)/po/LINGUAS
+
+PO4A_COMMON_OPTS = --option doctype=docbook \
+		   --package-name $(PACKAGE_DOC) \
+		   --package-version $(PACKAGE_VERSION) \
+		   --msgid-bugs-address sssd-devel at redhat.com \
+		   --copyright-holder "Red Hat"
+PO4A_TRANSLATE_OPTS = --option doctype=docbook -f docbook
+
+
+# The list of files to translate
+XML_DOC=$(wildcard *.xml) $(wildcard include/*.xml)
+LANGUAGES=$(shell $(SED) 's/\#.*//' $(LINGUAS))
+
+EXTRA_DIST += \
+	$(POTFILE)	\
+	$(PO4A_CONFIG)  \
+	$(LINGUAS)	\
+	$(LANGUAGES:%=po/%.po)
+
+if HAVE_PO4A
+
+prepare.stamp: $(LINGUAS)
+	$(mkdir_p) po
+	for lang in $(LANGUAGES); do \
+		$(mkdir_p) $$lang; \
+		$(mkdir_p) $$lang/include; \
+	done
+	touch $@
+
+$(PO4A_CONFIG): $(XML_DOC)
+	rm -f $@
+	echo "[po4a_langs] $(shell $(SED) 's/\#.*//' $(LINGUAS))" >> $@
+	echo "[po4a_paths] $(POTFILE) \$$lang:po/\$$lang.po" >> $@
+	for file in $(XML_DOC); do \
+	    echo "[type:docbook] $$file \$$lang:\$$lang/$$file" >> $@; \
+	done
+
+# Extract translatable strings from the original Docbook sources
+$(POTFILE): $(XML_DOC) $(PO4A_CONFIG)
+	$(PO4A) $(PO4A_COMMON_OPTS) --no-backups --no-translations $(PO4A_CONFIG)
+
+update-po: $(POTFILE)
+
+# Generate translated XML documents from the .PO files
+translate-xml.stamp: prepare.stamp
+	for lang in $(LANGUAGES); do \
+	    if [ -d $$lang ]; then \
+		for man in $(notdir $(wildcard $(srcdir)/include/*.xml)); do \
+			$(PO4A_TRANSLATE) $(PO4A_TRANSLATE_OPTS) --keep 0 \
+					  -m $(srcdir)/include/$$man \
+					  -p $(srcdir)/po/$$lang.po  \
+					  -l $(builddir)/$$lang/include/$$man; \
+		done; \
+		for man in $(man_MANS:%=%.xml); do \
+		    $(PO4A_TRANSLATE) $(PO4A_TRANSLATE_OPTS) \
+ 		      		      -m $(srcdir)/$$man \
+				      -p $(srcdir)/po/$$lang.po \
+				      -l $(builddir)/$$lang/$$man; \
+		done; \
+	    fi \
+	done
+	touch $@
+
+# Generate translated manual pages
+translate: translate-xml.stamp
+	if [ -z $$recursion ]; then \
+	    for lang in $(LANGUAGES); do \
+		if [ -d $$lang ]; then \
+		    sources=$$(ls $$lang/*.xml); \
+		    manpages=$$(echo $$sources | $(SED) 's/\.xml//'); \
+		    $(MAKE) recursion=1 man_MANS="$$manpages"; \
+		fi \
+	    done \
+	fi
+
+dist-hook: translate-xml.stamp
+
+clean-local: clean-local- at USE_NLS@
+distclean-local: clean-local- at USE_NLS@
+mostlyclean-local: clean-local- at USE_NLS@
+maintainer-clean-local: clean-local- at USE_NLS@
+
+clean-local-no:
+clean-local-yes:
+	if [ -f $(PO4A_CONFIG) ]; then \
+		$(PO4A) --rm-backups --rm-translations $(PO4A_CONFIG); \
+		rm -f $(PO4A_CONFIG); \
+	fi
+	for lang in $(LANGUAGES); do \
+	    if [ -d $$lang ]; then \
+	    	rm -rf $$lang;	   \
+	    fi \
+	done
+	rm -f prepare.stamp
+	rm -f translate-xml.stamp
+	rm -f $(man_MANS)
+
+install-data-local: install-data-local- at USE_NLS@
+install-data-local-no:
+install-data-local-yes:
+	for lang in $(LANGUAGES); do \
+	    if [ -d $$lang ]; then \
+		sources=$$(ls $$lang/*.xml); \
+		manpages=$$(echo $$sources | $(SED) 's/\.xml//'); \
+		$(MAKE) install-man \
+			mandir="$(mandir)/$$lang" \
+			man_MANS="$$manpages"; \
+	    fi \
+	done
+
+uninstall-local: uninstall-local- at USE_NLS@
+uninstall-local-no:
+uninstall-local-yes:
+	for lang in $(LANGUAGES); do \
+	    if [ -d $$lang ]; then \
+		sources=$$(ls $$lang/*.xml); \
+		manpages=$$(echo $$sources | $(SED) 's/\.xml//'); \
+		$(MAKE) uninstall-man \
+			mandir="$(mandir)/$$lang" \
+			man_MANS="$$manpages"; \
+	    fi \
+	done
+
+else
+translate:
+	@echo No po4a, skipping translations
+endif
diff --git a/src/man/sss_groupdel.8.xml b/src/man/sss_groupdel.8.xml
index 22f4fca..978fc73 100644
--- a/src/man/sss_groupdel.8.xml
+++ b/src/man/sss_groupdel.8.xml
@@ -13,7 +13,7 @@
 
     <refnamediv id='name'>
         <refname>sss_groupdel</refname>
-        <refpurpose>create a new group</refpurpose>
+        <refpurpose>delete a group</refpurpose>
     </refnamediv>
 
     <refsynopsisdiv id='synopsis'>
-- 
1.7.3.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-Czech-translation.patch.bz2
Type: application/x-bzip2
Size: 24882 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/sssd-devel/attachments/20101220/413ec317/attachment.bz2>
-------------- next part --------------
From c16c4ff05c85564ef4ea7fa8a0cd4127210a5ef8 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Mon, 20 Dec 2010 13:42:07 +0100
Subject: [PATCH 3/3] Update man pages pot file during make dist

---
 src/man/Makefile.am |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/man/Makefile.am b/src/man/Makefile.am
index f66babe..2d70871 100644
--- a/src/man/Makefile.am
+++ b/src/man/Makefile.am
@@ -60,7 +60,7 @@ PO4A_TRANSLATE_OPTS = --option doctype=docbook -f docbook
 
 
 # The list of files to translate
-XML_DOC=$(wildcard *.xml) $(wildcard include/*.xml)
+XML_DOC=$(wildcard $(srcdir)/*.xml) $(wildcard $(srcdir)/include/*.xml)
 LANGUAGES=$(shell $(SED) 's/\#.*//' $(LINGUAS))
 
 EXTRA_DIST += \
@@ -79,10 +79,10 @@ prepare.stamp: $(LINGUAS)
 	done
 	touch $@
 
-$(PO4A_CONFIG): $(XML_DOC)
+$(PO4A_CONFIG): $(XML_DOC) prepare.stamp
 	rm -f $@
 	echo "[po4a_langs] $(shell $(SED) 's/\#.*//' $(LINGUAS))" >> $@
-	echo "[po4a_paths] $(POTFILE) \$$lang:po/\$$lang.po" >> $@
+	echo "[po4a_paths] $(POTFILE) \$$lang:$(srcdir)/po/\$$lang.po" >> $@
 	for file in $(XML_DOC); do \
 	    echo "[type:docbook] $$file \$$lang:\$$lang/$$file" >> $@; \
 	done
@@ -125,7 +125,8 @@ translate: translate-xml.stamp
 	    done \
 	fi
 
-dist-hook: translate-xml.stamp
+distdir-hook:
+	$(MAKE) update-po
 
 clean-local: clean-local- at USE_NLS@
 distclean-local: clean-local- at USE_NLS@
-- 
1.7.3.2



More information about the sssd-devel mailing list