1 # dgit document translation machinery
3 # Translators: there is no need to look at this file. It contains
4 # complicated machinery which you do not need to understand :-).
5 # See po/README instead.
7 # Copyright (C)2018 Ian Jackson
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # ----- devel docs (translators, pleaee ignore all this) -----
24 # We use po4a for everything.
26 # po4a is nicely automatic for all the po handling, and the config
27 # file makes nice documentation, but it really really likes to dirty
28 # the tree. And we want to automatically list the documents and the
29 # translation languages which it doesn't make easy.
31 # The approach I have chosen is as follows:
35 # This is autogenerated. But also, we invite translators to add
36 # their own language to it. The resulting merge
37 # conflict/discrepancy will be just an alphabetical ordering
38 # discrepancy, since our generation script scans the available po
41 # Generation is done by a shell script, ./list-documents.
43 # make targets: po4a.cfg # many others imply this
44 # po4a.cfg.check # fails if out of date
48 # As far as translators are concerned, generated and maintained by
49 # po4a and committed to git. As for the developers, we update this
50 # occasionally just by running po4a.
52 # make targets: default } mean
55 # Translations for translators:
57 # make targets: preview.LANG
60 # Translated document source-language files (eg, translated pod):
62 # Like with normal po things, the tools don't like to generate
63 # output without updating (dirtying) the .po files. But with po4a
64 # this is really hard to avoid. So we use a linkfarming technique.
66 # make targets: translated-only
68 # Translated output files (roff format, from pod2man):
70 # We have sort of lost the usual make rule information by now
71 # about targets and what to build. Only po4a knows which
72 # translated files are supposed to exist. So we have a shell
73 # script which reuses the top-level Makefile to run pod2man
74 # where appropriate, and generate a further even-more-output-ish
77 # make targets: install
82 # pairwise-pocheck.check
87 include ../i18n-common.make
90 all update: translated
92 check: po4a.cfg.check pairwise-pocheck.check
95 $(PO4A) --no-translations $<
100 po4a.cfg: list-documents
103 po4a.cfg.check: list-documents
107 pairwise-pocheck.check:
110 t = ../.po4a.translated-only
113 translated-only: po4a.cfg pairwise-pocheck.check
114 rm -rf $t && mkdir $t
115 cd $t && ln -s $p/*.po $p/*.pot $p/po4a.cfg .
116 cd $t && $(PO4A) po4a.cfg
117 ! test -d $t/translated || \
118 cp -al --remove-destination $t/translated .
120 .po4a.%.cfg: po4a.cfg Makefile
121 $S perl -p -e 's{^(\[po4a_langs\]).*}{$$1 $*};' \
122 -e 's{:translated/man}{:.$*.translated/man}' \
125 .PRECIOUS: .po4a.%.cfg
127 pairwise-pocheck.%.check:
128 @tclsh /dev/null || printf ':;:; Please run apt-get install tcl\n'
129 ./pairwise-pocheck $*
131 preview.%: .po4a.%.cfg pairwise-pocheck.%.check
133 $S ./install-documents >/dev/null .$*.translated $@
134 @ echo '# runes to preview the various final tranlated manpages:'
135 $S find $@ -type f -printf 'man -l %p\n'
137 # We can't really use timestamps to drive po4a
138 .PHONY: preview.% translated
140 install: translated-only
141 ./install-documents translated $(DESTDIR)