1 # The availaible translation languages.
2 # When starting a new translation, add a language code here.
4 # Vietnamese PDF generation fails, since DocBook lacks Vietnamese support.
5 # I hope to work around this, or use another tool to generate a PDF from
8 # For now, I've uploaded a PDF to the website; it was supplied by
9 # Trần Ngọc Quân who used OpenOffice to convert HTML to PDF.
10 TRANSLATIONS
= de es fr ru vi zh_cn zh_tw
11 LANGS
= en
$(TRANSLATIONS
)
14 .PHONY
: all clean sync public
$(LANGS
)
18 $(LANGS
): %: book-
% book-
%/default.css book-
%.html book-
%.pdf
20 # The book consists of these text files in the following order:
22 TXTFILES
:= preface.txt intro.txt basic.txt clone.txt branch.txt history.txt \
23 multiplayer.txt grandmaster.txt secrets.txt drawbacks.txt translate.txt
25 $(foreach l
,$(LANGS
),book-
$(l
).xml
): book-
%.xml
: $(addprefix %/,$(TXTFILES
))
26 # Concatenate the text files and feed to AsciiDoc.
27 # If a file has not yet been translated for the target language,
28 # then substitute the English version.
29 # Kludge to support any translation of "Preface".
30 echo
'[specialsections]' > conf
; \
31 if
[ $* != ru
]; then \
32 sed
-n
'/^== .* ==$$/p' $*/preface.txt | sed
's/^== \(.*\) ==$$/^\1$$=preface/' >> conf
; \
34 cp lang-ru.conf conf
; fi
; \
35 ( for FILE in
$^
; do if
[ -f
$$FILE ]; then cat
$$FILE; else \
36 cat en
/$$(basename $$FILE); fi
; echo
; done
) | \
37 asciidoc
-a lang
=$* -d book
-b docbook
-f conf
- > $@
39 # This rule allows unfinished translations to build.
40 # Report an error if the English version of the text file is missing.
41 $(addprefix en
/,$(TXTFILES
)):
42 @if
[ ! -f
$@
]; then echo English file missing
: $@
; exit
123; fi
43 $(foreach l
,$(TRANSLATIONS
),$(addprefix $(l
)/,$(TXTFILES
))):
44 @if
[ ! -f
$@
]; then echo
$@ missing
: using English version
; fi
46 # Ignore tidy's exit code because Asciidoc generates section IDs beginning with
47 # "_", which xmlto converts to "id" attributes of <a> tags. The standard
48 # insists that "id" attributes begin with a letter, which causes tidy to
49 # print a warning and return a nonzero code.
51 # When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
52 # of ignoring return codes.
54 $(foreach l
,$(LANGS
),book-
$(l
)): book-
%: book-
%.xml
55 xmlto
-m custom-html.xsl
-o book-
$* html book-
$*.xml
56 sed
-i
'' -e
's/xmlns:fo[^ ]*//g' book-
$*/*.html
57 -ls book-
$*/*.html | xargs
-n
1 tidy
-utf8
-m
-i
-q
60 $(foreach l
,$(LANGS
),book-
$(l
)/default.css
): book-
%/default.css
: book.css
62 rsync book.css book-
$*/default.css
64 $(foreach l
,$(LANGS
),book-
$(l
).html
): book-
%.html
: book-
%.xml
65 xmlto
-m custom-nochunks.xsl html-nochunks
$^
68 # Set SP_ENCODING to avoid "non SGML character" errors.
69 # Can also do SP_ENCODING="UTF-8".
70 $(foreach l
,$(LANGS
),book-
$(l
).pdf
): book-
%.pdf
: book-
%.xml
71 if
[ $* = zh_cn
-o
$* = zh_tw
]; then \
72 if
! [ -f fop-
$*.xsl
]; then wget
-q http
://bestrecords.net
/fop
/fop-
$*.xsl
; fi
; \
73 if
! [ -f fop-
$*.xconf
]; then wget
-q http
://bestrecords.net
/fop
/fop-
$*.xconf
; fi
; \
74 xmlto
-m fop-
$*.xsl
--with-fop
-p
"-c `pwd`/fop-$*.xconf" pdf book-
$*.xml
;\
76 SP_ENCODING
="XML" docbook2pdf book-
$*.xml
; \
80 -rm -rf
$(foreach l
,$(LANGS
),book-
$(l
).pdf book-
$(l
).xml book-
$(l
).html book-
$(l
))