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 all: translated-always
85 po4a --no-translations $<
87 e=set -e; exec >$@.tmp
92 # Set S='' to see commands being run
97 po4a.cfg: list-documents
100 po4a.cfg.check: list-documents
104 t = ../.po4a.translated-only
107 translated-only: po4a.cfg
108 rm -rf $t && mkdir $t
109 cd $t && ln -s $p/*.po $p/*.pot $p/po4a.cfg .
110 cd $t && po4a po4a.cfg
111 ! test -d $t/translated || \
112 cp -al --remove-destination $t/translated .
114 .po4a.%.cfg: po4a.cfg Makefile
115 $S perl -p -e 's{^(\[po4a_langs\]).*}{$$1 $*};' \
116 -e 's{:translated/man}{:.$*.translated/man}' \
119 .PRECIOUS: .po4a.%.cfg
121 preview.%: .po4a.%.cfg
123 $S ./install-documents >/dev/null .$*.translated $@
124 @ echo '# runes to preview the various final tranlated manpages:'
125 $S find $@ -type f -printf 'man -l %p\n'
127 # We can't really use timestamps to drive po4a
128 .PHONY: preview.% translated
130 install: translated-only
131 ./install-documents translated $(DESTDIR)