build-sys: Use po4a for manpage translations

Using the newer po4a tool for manpage translations. Also removing
the manpage po file update from dist target because it should be
something the is explicitly done.

The git repository will hold the original man pages and the
po translation files. The distribution tarball will hold those
and the translated manpages. This means most people won't need po4a
as the distribution fill will have these translated manpages.
This commit is contained in:
Craig Small 2019-11-11 21:41:00 +11:00
parent e79095ddcc
commit 2590e3be42
5 changed files with 84 additions and 132 deletions

1
.gitignore vendored
View File

@ -28,6 +28,7 @@ kill
libtool
ltmain.sh
m4/
man-po/translated
Makefile
Makefile.in
missing

View File

@ -353,5 +353,3 @@ get-trans:
echo "Getting the latest translations from translationproject.org..."
rsync -Lrtvz translationproject.org::tp/latest/procps-ng/ po
rsync -Lrtvz translationproject.org::tp/latest/procps-ng-man/ man-po
rsync -Lrtvz translationproject.org::tp/latest/procps-ng-man-ps/ man-po/ps
rsync -Lrtvz translationproject.org::tp/latest/procps-ng-man-top/ man-po/top

View File

@ -42,6 +42,12 @@ AC_PROG_LN_S
PKG_PROG_PKG_CONFIG
AC_PROG_MAKE_SET
AC_PATH_PROG(PO4A, po4a)
if test "xPO4A" = "x" ; then
AM_CONDITIONAL(USE_PO4A, false)
else
AM_CONDITIONAL(USE_PO4A, true)
fi
# Checks for header files.
AC_HEADER_MAJOR
AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h langinfo.h libintl.h limits.h locale.h netinet/in.h stdint.h stdio_ext.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/time.h termios.h unistd.h utmp.h values.h wchar.h wctype.h])

View File

@ -1,141 +1,35 @@
translate-templates: $(DIST_MAN_POTS)
EXTRA_DIST = $(DIST_MAN_POTS) $(DIST_MAN_POS) $(DIST_translated_MANS)
# *.po and *.pot are kept in VCS and generated by po4a-dist command
# translated/* are put in distribution but not found in VCS
#
# run:
# make -C man-po po4a-dist
# To update man page translations
DIST_translated_MANS = $(shell find translated -name '*.[1-9]')
EXTRA_DIST = po4a.cfg $(DIST_translated_MANS)
if USE_PO4A
po4a-dist:
-@po4a -M utf-8 -k 0 po4a.cfg
endif
get-trans:
rsync -Lrtvz translationproject.org::tp/latest/procps-ng-man/ .
rsync -Lrtvz translationproject.org::tp/latest/procps-ng-man-ps/ ps
rsync -Lrtvz translationproject.org::tp/latest/procps-ng-man-top/ top
translate-mans: $(translated_MANS)
translated_langs = $(notdir $(wildcard translated/*))
base_langs = $(patsubst %.po,%,$(wildcard *.po))
top_langs = $(patsubst %.po,%,$(notdir $(wildcard top/*.po)))
ps_langs = $(patsubst %.po,%,$(notdir $(wildcard ps/*.po)))
all_langs = $(base_langs) $(top_langs) $(ps_langs)
DIST_MAN_POS = $(wildcard *.po) $(wildcard top/*.po) $(wildcard ps/*.po)
DIST_translated_MANS = $(shell find . -name '*.[1-9]')
MAN_SECTIONS = 1 5 8
MAN_PAGES = free.1 kill.1 pgrep.1 pidof.1 pkill.1 pmap.1 pwdx.1 skill.1 slabtop.1 \
tload.1 uptime.1 w.1 watch.1 \
sysctl.conf.5 \
sysctl.8 vmstat.8
man1_pages := $(foreach man,$(filter %.1, $(MAN_PAGES)), man1/$(man))
man5_pages := $(foreach man,$(filter %.5, $(MAN_PAGES)), man5/$(man))
man8_pages := $(foreach man,$(filter %.8, $(MAN_PAGES)), man8/$(man))
man_pages = $(man1_pages) $(man8_pages)
man_paths = $(foreach lang, $(base_langs), $(foreach section,$(MAN_SECTIONS),$(lang)/man$(section))) \
$(foreach lang, $(top_langs), $(lang)/man1) \
$(foreach lang, $(ps_langs), $(lang)/man1)
translated_MANS :=$(foreach lang,$(base_langs), $(foreach manpage,$(man_pages),$(lang)/$(manpage)))
translated_MANS +=$(foreach lang,$(top_langs), $(lang)/man1/top.1)
translated_MANS +=$(foreach lang,$(ps_langs), $(lang)/man1/ps.1)
PO4A_UPDATEPO = po4a-updatepo
PO4A_TRANSLATE = po4a-translate
translate_manpage = $(PO4A_TRANSLATE) -o translate_joined=MT -o noarg=ME -f man -m $< -p $*.po -l $@
CLEANFILES = $(DIST_MAN_POTS) $(translated_MANS)
maintainer-clean-local:
-rm -rf $(all_langs)
MAN_PS_POT = template-man-ps.pot
MAN_PS_POT_FILES = $(top_srcdir)/ps/ps.1
MAN_TOP_POT = template-man-top.pot
MAN_TOP_POT_FILES = $(top_srcdir)/top/top.1
MAN_POT = template-man.pot
MAN_POT_FILES = $(top_srcdir)/free.1 $(top_srcdir)/kill.1 $(top_srcdir)/pgrep.1 \
$(top_srcdir)/pidof.1 $(top_srcdir)/pkill.1 $(top_srcdir)/pmap.1 \
$(top_srcdir)/pwdx.1 $(top_srcdir)/skill.1 $(top_srcdir)/slabtop.1 \
$(top_srcdir)/snice.1 $(top_srcdir)/sysctl.8 $(top_srcdir)/uptime.1 \
$(top_srcdir)/sysctl.conf.5 $(top_srcdir)/tload.1 \
$(top_srcdir)/vmstat.8 $(top_srcdir)/w.1 $(top_srcdir)/watch.1
DIST_MAN_POTS = $(MAN_PS_POT) $(MAN_TOP_POT) $(MAN_POT)
$(MAN_PS_POT): $(MAN_PS_POT_FILES)
$(eval po4a_manfiles := $(foreach manfile,$^,$(addprefix -m , $(manfile))))
$(PO4A_UPDATEPO) -o translate_joined=MT -o noarg=ME -f man $(po4a_manfiles) -p $@
$(MAN_TOP_POT): $(MAN_TOP_POT_FILES)
$(eval po4a_manfiles := $(foreach manfile,$^,$(addprefix -m , $(manfile))))
$(PO4A_UPDATEPO) -o translate_joined=MT -o noarg=ME -f man $(po4a_manfiles) -p $@
$(MAN_POT): $(MAN_POT_FILES)
$(eval po4a_manfiles := $(foreach manfile,$^,$(addprefix -m , $(manfile))))
$(PO4A_UPDATEPO) -o translate_joined=MT -o noarg=ME -f man $(po4a_manfiles) -p $@
man_MANS := $(foreach lang, $(all_langs), $(foreach section, $(MAN_SECTIONS), $(wildcard $(lang)/man$(section)/*.$(section))))
dist-hook: translate-mans
echo $(translated_MANS)
install-data-local: translate-mans
for l in $(base_langs) ; do \
for sect in `ls $$l` ; do \
install-data-local:
for l in $(translated_langs) ; do \
for sect in `ls translated/$$l` ; do \
$(MKDIR_P) $(DESTDIR)$(mandir)/$$l/$$sect ; \
for file in `ls $$l/$$sect` ; do \
$(INSTALL_DATA) $$l/$$sect/$$file $(DESTDIR)$(mandir)/$$l/$$sect ; \
for file in `ls translated/$$l/$$sect` ; do \
$(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/$$l/$$sect ; \
done ; \
done ; \
done
# My Makefile-fu fails me here, I cannot see how to have double-wildcards
# or have rules and recipies split
#
%/man1/top.1: ../top/top.1 top/%.po
$(PO4A_TRANSLATE) -f man -m $< -p top/$*.po -l $@
%/man1/ps.1: ../ps/ps.1 ps/%.po
$(PO4A_TRANSLATE) -f man -m $< -p ps/$*.po -l $@
%/man1/free.1: ../free.1 %.po
$(translate_manpage)
%/man1/kill.1: ../kill.1 %.po
$(translate_manpage)
%/man1/pgrep.1: ../pgrep.1 %.po
$(translate_manpage)
%/man1/pidof.1: ../pidof.1 %.po
$(translate_manpage)
%/man1/pkill.1: ../pkill.1 %.po
$(translate_manpage)
%/man1/pmap.1: ../pmap.1 %.po
$(translate_manpage)
%/man1/pwdx.1: ../pwdx.1 %.po
$(translate_manpage)
%/man1/skill.1: ../skill.1 %.po
$(translate_manpage)
%/man1/slabtop.1: ../slabtop.1 %.po
$(translate_manpage)
%/man1/tload.1: ../tload.1 %.po
$(translate_manpage)
%/man1/uptime.1: ../uptime.1 %.po
$(translate_manpage)
%/man1/w.1: ../w.1 %.po
$(translate_manpage)
%/man1/watch.1: ../watch.1 %.po
$(translate_manpage)
%/man5/sysctl.conf.5: ../sysctl.conf.5 %.po
$(translate_manpage)
%/man8/sysctl.8: ../sysctl.8 %.po
$(translate_manpage)
%/man8/vmstat.8: ../vmstat.8 %.po
$(translate_manpage)
.PHONY = translate-mans dist-man-paths
.PHONY = translated_langs get-trans po4a-dist

53
man-po/po4a.cfg Normal file
View File

@ -0,0 +1,53 @@
[po_directory] .
[type: man] ../free.1 $lang:translated/$lang/free.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../kill.1 $lang:translated/$lang/kill.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../pgrep.1 $lang:translated/$lang/pgrep.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../pidof.1 $lang:translated/$lang/pidof.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../pmap.1 $lang:translated/$lang/pmap.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../pwdx.1 $lang:translated/$lang/pwdx.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../skill.1 $lang:translated/$lang/skill.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../slabtop.1 $lang:translated/$lang/slabtop.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../sysctl.8 $lang:translated/$lang/sysctl.8 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../sysctl.conf.5 $lang:translated/$lang/sysctl.conf.5 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../tload.1 $lang:translated/$lang/tload.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../uptime.1 $lang:translated/$lang/uptime.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../vmstat.8 $lang:translated/$lang/vmstat.8 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../w.1 $lang:translated/$lang/w.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../watch.1 $lang:translated/$lang/watch.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../ps/ps.1 $lang:translated/$lang/ps.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
[type: man] ../top/top.1 $lang:translated/$lang/top.1 \
add_$lang:?add_$lang/$lang.add opt:"-k 80"
#../watch.1