[Dctrl-tools-devel] Bug#615877: dctrl-tools: Internationalise the man pages

David Prévot david at tilapin.org
Mon Feb 28 17:34:37 UTC 2011


Package: dctrl-tools
Version: 2.19
Severity: normal
Tags: patch l10n

Hi,

Please find the following patch against your Git repository in order to
fix the third point of your RFH #448284. Note that I'm not a Makefile
expert, so there may be a better way to provide the needed parts. The
tests and loops goal is to avoid the need of editing it if a new
translation is added, a translated manpage is removed (because the
original changed and the PO file is not yet updated), and even to work
if no translation at all is provided.
If such tests and loops are fine in a GNUmakefile, it may be easier to
provide manpages name in a list and just have to edit that list to
update both the original and translated manpages names that have to be
shipped (I'm willing to provide a patch if you agree with such
approach).

Regards

David

*** 0003-Makes-manpages-translatable-using-po4a.patch
>From d9bf1a26b8ceba18d0d990544f3a4c196cc466fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Pr=C3=A9vot?= <david at tilapin.org>
Date: Sun, 27 Feb 2011 15:54:02 -0400
Subject: [PATCH 3/5] Makes manpages translatable (using po4a)

---
 GNUmakefile                |   53 ++++++++++++++++++++++++++++++++++++++++---
 debian/control             |    2 +-
 man/.gitignore             |    1 +
 man/po4a/addendum.template |   22 ++++++++++++++++++
 man/po4a/po/.gitignore     |    2 +
 man/po4a/po4a.cfg          |   14 +++++++++++
 6 files changed, 89 insertions(+), 5 deletions(-)
 create mode 100644 man/po4a/addendum.template
 create mode 100644 man/po4a/po/.gitignore
 create mode 100644 man/po4a/po4a.cfg

diff --git a/GNUmakefile b/GNUmakefile
index 7301663..6c23678 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -27,6 +27,9 @@ INSTALL_PROGRAM = $(INSTALL)
 INSTALL_DATA = $(INSTALL) -m644
 INSTALL_DIR = $(INSTALL) -d
 
+PO4A = po4a
+PO4A_CONFIG = man/po4a/po4a.cfg
+
 libsrc = $(wildcard lib/*.c)
 libobj = $(libsrc:.c=.o)
 
@@ -48,7 +51,7 @@ LDLIBS = -L. -ldctrl
 # List of translated languages is given in langs.mk
 include langs.mk
 
-all :	all-no-mo mo
+all :	all-no-mo mo translated-man
 
 all-no-mo :	sync-available/sync-available \
 		man/grep-dctrl.1 \
@@ -84,7 +87,29 @@ install :
 	gzip -9 $(DESTDIR)$(man1dir)/grep-dctrl.1
 	set -e ; for dest in $(aliases) ; do \
 		ln -s grep-dctrl.1.gz $(DESTDIR)$(man1dir)/$$dest.1.gz ; \
-	 done
+	done
+	set -e ; for d in man/translated/*; do \
+		lang=`echo $$d | cut -c16-`; \
+		if [ -e $$d/sync-available.8 ]; then \
+			$(INSTALL_DIR) $(DESTDIR)$(mandir)/$$lang/man8; \
+			$(INSTALL_DATA) $$d/sync-available.8 $(DESTDIR)$(mandir)/$$lang/man8/; \
+			gzip -9 $(DESTDIR)$(mandir)/$$lang/man8/sync-available.8; \
+		fi; \
+		for file in sort-dctrl.1 tbl-dctrl.1 join-dctrl.1 grep-dctrl.1; do \
+			if [ -e $$d/$$file ]; then \
+				if ! [ -d $(DESTDIR)$(mandir)/$$lang/man1 ]; then \
+					$(INSTALL_DIR) $(DESTDIR)$(mandir)/$$lang/man1; \
+				fi; \
+				$(INSTALL_DATA) $$d/$$file $(DESTDIR)$(mandir)/$$lang/man1/; \
+				gzip -9 $(DESTDIR)$(mandir)/$$lang/man1/$$file; \
+			fi; \
+		done; \
+		if [ -e $(DESTDIR)$(mandir)$$lang/man1/grep-dctrl.1.gz ]; then \
+			for dest in $(aliases) ; do \
+				ln -s grep-dctrl.1.gz $(DESTDIR)$(mandir)/$$lang/man1/$$dest.1.gz ; \
+			done; \
+		fi; \
+	done;
 	$(INSTALL_DATA) TODO README $(DESTDIR)$(docdir)
 	set -e ; for lang in $(langs) ; do \
 		$(INSTALL_DIR) $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES ; \
@@ -93,7 +118,7 @@ install :
 	done
 
 
-pot : po/dctrl-tools.pot
+pot : po/dctrl-tools.pot man/po4a/po/dctrl-tools-man.pot
 
 po : $(foreach f,$(langs),po/$(f).po)
 
@@ -154,6 +179,25 @@ po/dctrl-tools.pot : $(src)
 	xgettext $(xgettext_opts) -d grep-dctrl $^
 	mv grep-dctrl.po $@
 
+# create (or update) dctrl-tools-man.pot
+man/po4a/po/dctrl-tools-man.pot :
+	touch man/po4a/po/dctrl-tools-man.pot
+	$(PO4A) --force --no-translations $(PO4A_CONFIG)
+
+# build translated manpages in man/translated/$lang/
+po4a :
+	touch man/po4a/po/dctrl-tools-man.pot
+	$(PO4A) --force --no-backups $(PO4A_CONFIG)
+
+# handle the "%.1 : %.1.cp" rule if and only if the grep-dctrl.1.cp file exists
+translated-man : po4a
+	set -e ; for d in man/translated/*; do \
+		if [ -e $$d/grep-dctrl.1.cp ]; then \
+			sed 's*SYSCONF*$(sysconfdir)*' \
+			$$d/grep-dctrl.1.cp > $$d/grep-dctrl.1; \
+		fi; \
+       done
+
 fsaf.test : fsaf.test.o msg.o
 
 test :	all-no-mo
@@ -163,11 +207,12 @@ clean :
 	$(RM) core $(exe) man/grep-dctrl.1 $(obj) so/*.o libdctrl.a libdctrl.so
 	$(RM) po/*.mo TAGS *.d */*.d
 	$(RM) sync-available/sync-available
+	$(RM) -r man/translated
 
 distclean : clean
 
 maintainer-clean : distclean
-	$(RM) po/*.pot
+	$(RM) po/*.pot man/po4a/po/*.pot
 
 tags :
 	etags *.[hc]
diff --git a/debian/control b/debian/control
index b5e635e..4db1e2c 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
 Maintainer: dctrl-tools developers <dctrl-tools-devel at lists.alioth.debian.org>
 Uploaders: Antti-Juhani Kaijanaho <ajk at debian.org>
 Standards-Version: 3.9.1
-Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 8)
+Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 8), po4a (>= 0.40)
 Vcs-Git: git://git.debian.org/git/collab-maint/dctrl-tools.git
 Vcs-Browser: http://git.debian.org/?p=collab-maint/dctrl-tools.git;a=summary
 
diff --git a/man/.gitignore b/man/.gitignore
index 5ef3e00..e171ca3 100644
--- a/man/.gitignore
+++ b/man/.gitignore
@@ -1 +1,2 @@
 grep-dctrl.1
+translated
diff --git a/man/po4a/addendum.template b/man/po4a/addendum.template
new file mode 100644
index 0000000..d453494
--- /dev/null
+++ b/man/po4a/addendum.template
@@ -0,0 +1,22 @@
+PO4A-HEADER:mode=after;position=^\.SH "SEE ALSO";beginboundary=^\.SH
+.SH TRANSLATOR(S)
+This manpage has been translated by TRANSLATOR NAME <email> on TRANSLATION
+DATE.
+
+If you find any mistake in this translation, please send an e-mail to the
+translator or to the
+.nh
+<\fIdebian\-l10n\-LANGUAGE at lists.debian.org\fR>,
+.hy
+mailing-list.
+
+# Note to translators:
+# Please translate this text in a file called language_code.add
+# The addendum MUST use the same encoding as your po file
+# Feel free to adapt the text at your convenience.
+# Do not forget to translate "SEE ALSO" and "TRANSLATOR(S)"
+# The "SEE ALSO" part in the header must be *exactly* the same translation
+# as the one in your xx.po file.
+# Do not include this comment in your addendum (i.e. all lines starting
+# with a #).
+# See po4a(7) for further information.
diff --git a/man/po4a/po/.gitignore b/man/po4a/po/.gitignore
new file mode 100644
index 0000000..07fd2eb
--- /dev/null
+++ b/man/po4a/po/.gitignore
@@ -0,0 +1,2 @@
+*~
+dctrl-tools-man.pot
diff --git a/man/po4a/po4a.cfg b/man/po4a/po4a.cfg
new file mode 100644
index 0000000..ace0f69
--- /dev/null
+++ b/man/po4a/po4a.cfg
@@ -0,0 +1,14 @@
+[po_directory] man/po4a/po/
+
+[po4a_alias:man] man opt:"-M UTF-8 -L UTF-8"
+
+[type: man] man/grep-dctrl.1.cp		$lang:man/translated/$lang/grep-dctrl.1.cp \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/join-dctrl.1		$lang:man/translated/$lang/join-dctrl.1 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/sort-dctrl.1		$lang:man/translated/$lang/sort-dctrl.1 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/sync-available.8	$lang:man/translated/$lang/sync-available.8 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/tbl-dctrl.1		$lang:man/translated/$lang/tbl-dctrl.1 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
-- 
1.7.4.1


*** 0003-Makes-manpages-translatable-using-po4a.patch
>From 8c80c0da5f99bc0ab3238df62e57b18c2d784731 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Pr=C3=A9vot?= <david at tilapin.org>
Date: Sun, 27 Feb 2011 15:54:02 -0400
Subject: [PATCH 3/5] Makes manpages translatable (using po4a)

---
 GNUmakefile                |   53 ++++++++++++++++++++++++++++++++++++++++---
 debian/control             |    2 +-
 man/.gitignore             |    1 +
 man/po4a/addendum.template |   22 ++++++++++++++++++
 man/po4a/po/.gitignore     |    2 +
 man/po4a/po4a.cfg          |   14 +++++++++++
 6 files changed, 89 insertions(+), 5 deletions(-)
 create mode 100644 man/po4a/addendum.template
 create mode 100644 man/po4a/po/.gitignore
 create mode 100644 man/po4a/po4a.cfg

diff --git a/GNUmakefile b/GNUmakefile
index 7301663..9ec2ec2 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -27,6 +27,9 @@ INSTALL_PROGRAM = $(INSTALL)
 INSTALL_DATA = $(INSTALL) -m644
 INSTALL_DIR = $(INSTALL) -d
 
+PO4A = po4a
+PO4A_CONFIG = man/po4a/po4a.cfg
+
 libsrc = $(wildcard lib/*.c)
 libobj = $(libsrc:.c=.o)
 
@@ -48,7 +51,7 @@ LDLIBS = -L. -ldctrl
 # List of translated languages is given in langs.mk
 include langs.mk
 
-all :	all-no-mo mo
+all :	all-no-mo mo translated-man
 
 all-no-mo :	sync-available/sync-available \
 		man/grep-dctrl.1 \
@@ -84,7 +87,29 @@ install :
 	gzip -9 $(DESTDIR)$(man1dir)/grep-dctrl.1
 	set -e ; for dest in $(aliases) ; do \
 		ln -s grep-dctrl.1.gz $(DESTDIR)$(man1dir)/$$dest.1.gz ; \
-	 done
+	done
+	set -e ; for d in man/translated/*; do \
+		lang=`echo $$d | cut -c16-`; \
+		if [ -e $$d/sync-available.8 ]; then \
+			$(INSTALL_DIR) $(DESTDIR)$(mandir)/$$lang/man8; \
+			$(INSTALL_DATA) $$d/sync-available.8 $(DESTDIR)$(mandir)/$$lang/man8/; \
+			gzip -9 $(DESTDIR)$(mandir)/$$lang/man8/sync-available.8; \
+		fi; \
+		for file in sort-dctrl.1 tbl-dctrl.1 join-dctrl.1 grep-dctrl.1; do \
+			if [ -e $$d/$$file ]; then \
+				if ! [ -d $(DESTDIR)$(mandir)/$$lang/man1 ]; then \
+					$(INSTALL_DIR) $(DESTDIR)$(mandir)/$$lang/man1; \
+				fi; \
+				$(INSTALL_DATA) $$d/$$file $(DESTDIR)$(mandir)/$$lang/man1/; \
+				gzip -9 $(DESTDIR)$(mandir)/$$lang/man1/$$file; \
+			fi; \
+		done; \
+		if [ -e $(DESTDIR)$(mandir)/$$lang/man1/grep-dctrl.1.gz ]; then \
+			for dest in $(aliases) ; do \
+				ln -s grep-dctrl.1.gz $(DESTDIR)$(mandir)/$$lang/man1/$$dest.1.gz ; \
+			done; \
+		fi; \
+	done;
 	$(INSTALL_DATA) TODO README $(DESTDIR)$(docdir)
 	set -e ; for lang in $(langs) ; do \
 		$(INSTALL_DIR) $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES ; \
@@ -93,7 +118,7 @@ install :
 	done
 
 
-pot : po/dctrl-tools.pot
+pot : po/dctrl-tools.pot man/po4a/po/dctrl-tools-man.pot
 
 po : $(foreach f,$(langs),po/$(f).po)
 
@@ -154,6 +179,25 @@ po/dctrl-tools.pot : $(src)
 	xgettext $(xgettext_opts) -d grep-dctrl $^
 	mv grep-dctrl.po $@
 
+# create (or update) dctrl-tools-man.pot
+man/po4a/po/dctrl-tools-man.pot :
+	touch man/po4a/po/dctrl-tools-man.pot
+	$(PO4A) --force --no-translations $(PO4A_CONFIG)
+
+# build translated manpages in man/translated/$lang/
+po4a :
+	touch man/po4a/po/dctrl-tools-man.pot
+	$(PO4A) --force --no-backups $(PO4A_CONFIG)
+
+# handle the "%.1 : %.1.cp" rule if and only if the grep-dctrl.1.cp file exists
+translated-man : po4a
+	set -e ; for d in man/translated/*; do \
+		if [ -e $$d/grep-dctrl.1.cp ]; then \
+			sed 's*SYSCONF*$(sysconfdir)*' \
+			$$d/grep-dctrl.1.cp > $$d/grep-dctrl.1; \
+		fi; \
+       done
+
 fsaf.test : fsaf.test.o msg.o
 
 test :	all-no-mo
@@ -163,11 +207,12 @@ clean :
 	$(RM) core $(exe) man/grep-dctrl.1 $(obj) so/*.o libdctrl.a libdctrl.so
 	$(RM) po/*.mo TAGS *.d */*.d
 	$(RM) sync-available/sync-available
+	$(RM) -r man/translated
 
 distclean : clean
 
 maintainer-clean : distclean
-	$(RM) po/*.pot
+	$(RM) po/*.pot man/po4a/po/*.pot
 
 tags :
 	etags *.[hc]
diff --git a/debian/control b/debian/control
index b5e635e..4db1e2c 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
 Maintainer: dctrl-tools developers <dctrl-tools-devel at lists.alioth.debian.org>
 Uploaders: Antti-Juhani Kaijanaho <ajk at debian.org>
 Standards-Version: 3.9.1
-Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 8)
+Build-Depends: gettext (>= 0.11-0), gcc (>= 3.0), debhelper (>= 8), po4a (>= 0.40)
 Vcs-Git: git://git.debian.org/git/collab-maint/dctrl-tools.git
 Vcs-Browser: http://git.debian.org/?p=collab-maint/dctrl-tools.git;a=summary
 
diff --git a/man/.gitignore b/man/.gitignore
index 5ef3e00..e171ca3 100644
--- a/man/.gitignore
+++ b/man/.gitignore
@@ -1 +1,2 @@
 grep-dctrl.1
+translated
diff --git a/man/po4a/addendum.template b/man/po4a/addendum.template
new file mode 100644
index 0000000..d453494
--- /dev/null
+++ b/man/po4a/addendum.template
@@ -0,0 +1,22 @@
+PO4A-HEADER:mode=after;position=^\.SH "SEE ALSO";beginboundary=^\.SH
+.SH TRANSLATOR(S)
+This manpage has been translated by TRANSLATOR NAME <email> on TRANSLATION
+DATE.
+
+If you find any mistake in this translation, please send an e-mail to the
+translator or to the
+.nh
+<\fIdebian\-l10n\-LANGUAGE at lists.debian.org\fR>,
+.hy
+mailing-list.
+
+# Note to translators:
+# Please translate this text in a file called language_code.add
+# The addendum MUST use the same encoding as your po file
+# Feel free to adapt the text at your convenience.
+# Do not forget to translate "SEE ALSO" and "TRANSLATOR(S)"
+# The "SEE ALSO" part in the header must be *exactly* the same translation
+# as the one in your xx.po file.
+# Do not include this comment in your addendum (i.e. all lines starting
+# with a #).
+# See po4a(7) for further information.
diff --git a/man/po4a/po/.gitignore b/man/po4a/po/.gitignore
new file mode 100644
index 0000000..07fd2eb
--- /dev/null
+++ b/man/po4a/po/.gitignore
@@ -0,0 +1,2 @@
+*~
+dctrl-tools-man.pot
diff --git a/man/po4a/po4a.cfg b/man/po4a/po4a.cfg
new file mode 100644
index 0000000..ace0f69
--- /dev/null
+++ b/man/po4a/po4a.cfg
@@ -0,0 +1,14 @@
+[po_directory] man/po4a/po/
+
+[po4a_alias:man] man opt:"-M UTF-8 -L UTF-8"
+
+[type: man] man/grep-dctrl.1.cp		$lang:man/translated/$lang/grep-dctrl.1.cp \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/join-dctrl.1		$lang:man/translated/$lang/join-dctrl.1 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/sort-dctrl.1		$lang:man/translated/$lang/sort-dctrl.1 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/sync-available.8	$lang:man/translated/$lang/sync-available.8 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
+[type: man] man/tbl-dctrl.1		$lang:man/translated/$lang/tbl-dctrl.1 \
+					add_$lang:?man/po4a/add_$lang/$lang.add
-- 
1.7.4.1





More information about the Dctrl-tools-devel mailing list