chiark / gitweb /
sgt-puzzles (20161228.7cae89f-1) unstable; urgency=medium
[sgt-puzzles.git] / debian / patches / 206_translate-docs.diff
1 Author: Ben Hutchings <ben@decadent.org.uk>
2 Description: Support translated docs using po4a
3 Bug-Debian: https://bugs.debian.org/483665
4
5 --- a/Makefile.doc
6 +++ b/Makefile.doc
7 @@ -13,5 +13,37 @@ chm: puzzles.hhp
8  puzzles.hhp: puzzles.but chm.but
9         halibut --html puzzles.but chm.but
10  
11 +TRANSLATIONS := $(patsubst po/%.po,%,$(wildcard po/*.po))
12 +
13 +update-po:
14 +# Please tell me there is an easier way to preserve the POT file header.
15 +       test -f po/puzzles-doc.pot
16 +       po4a-gettextize -f halibut -m puzzles.but --package-name puzzles \
17 +               -p po/puzzles-doc.tmp1.pot
18 +       sed -i '1,/^#$$/d' po/puzzles-doc.tmp1.pot
19 +       cat po/puzzles-doc.pot.head po/puzzles-doc.tmp1.pot \
20 +               > po/puzzles-doc.tmp2.pot
21 +       diff -q -I Project-Id-Version: -I POT-Creation-Date: \
22 +               po/puzzles-doc.pot po/puzzles-doc.tmp2.pot || \
23 +               mv po/puzzles-doc.tmp2.pot po/puzzles-doc.pot
24 +       rm -f po/puzzles-doc.tmp*.pot
25 +       for lang in $(TRANSLATIONS); do \
26 +               msgmerge --previous -U po/$$lang.po po/puzzles-doc.pot || exit; \
27 +       done
28 +.PHONY: update-po
29 +
30 +doc/puzzles.but.%: puzzles.but po/%.po
31 +       mkdir -p doc
32 +       po4a-translate -k 0 -f halibut -m puzzles.but -p po/$*.po -l $@
33 +.PRECIOUS: $(addprefix doc/puzzles.but.,$(TRANSLATIONS))
34 +
35 +doc/preprocessed.but.%: doc/puzzles.but.%
36 +       sed 's/PREFIX-/$(BINPREFIX)/g' $< > $@
37 +
38 +doc/puzzles.txt.%: doc/preprocessed.but.%
39 +       halibut --text=$@ --input-charset=UTF-8 $<
40 +all: $(addprefix doc/puzzles.txt.,$(TRANSLATIONS))
41 +
42  clean:
43         rm -f puzzles.hlp puzzles.txt preprocessed.but HACKING *.html *.hh[pck]
44 +       rm -rf doc