1 # The availaible translation languages.
2 # When starting a new translation, add a language code here.
5 TRANSLATIONS
= de es fr ko pt_br ru uk vi zh_cn zh_tw it pl
6 LANGS
= en
$(TRANSLATIONS
)
9 .PHONY
: all clean sync public
distclean $(LANGS
)
13 $(LANGS
): %: book-
% book-
%/default.css book-
%.html book-
%.pdf book-
%.epub
15 # The book consists of these text files in the following order:
17 TXTFILES
:= preface.txt intro.txt basic.txt clone.txt branch.txt history.txt \
18 multiplayer.txt grandmaster.txt secrets.txt drawbacks.txt translate.txt
20 $(foreach l
,$(LANGS
),book-
$(l
).xml
): book-
%.xml
: $(addprefix %/,$(TXTFILES
))
21 # Concatenate the text files and feed to AsciiDoc.
22 # If a file has not yet been translated for the target language,
23 # then substitute the English version.
24 # Kludge to support any translation of "Preface".
25 echo
'[specialsections]' > conf
; \
26 if
[ $* != ru
]; then \
27 sed
-n
'/^== .* ==$$/p' $*/preface.txt | sed
's/^== \(.*\) ==$$/^\1$$=preface/' >> conf
; \
29 cp lang-ru.conf conf
; fi
; \
30 ( for FILE in
$^
; do if
[ -f
$$FILE ]; then cat
$$FILE; else \
31 cat en
/$$(basename $$FILE); fi
; echo
; done
) | \
32 asciidoc
-a lang
=$* -d book
-b docbook
-f conf
- > $@
34 # This rule allows unfinished translations to build.
35 # Report an error if the English version of the text file is missing.
36 $(addprefix en
/,$(TXTFILES
)):
37 @if
[ ! -f
$@
]; then echo English file missing
: $@
; exit
123; fi
38 $(foreach l
,$(TRANSLATIONS
),$(addprefix $(l
)/,$(TXTFILES
))):
39 @if
[ ! -f
$@
]; then echo
$@ missing
: using English version
; fi
41 # Ignore tidy's exit code because Asciidoc generates section IDs beginning with
42 # "_", which xmlto converts to "id" attributes of <a> tags. The standard
43 # insists that "id" attributes begin with a letter, which causes tidy to
44 # print a warning and return a nonzero code.
46 # When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
47 # of ignoring return codes.
49 $(foreach l
,$(LANGS
),book-
$(l
)): book-
%: book-
%.xml
50 xmlto
-m custom-html.xsl
-o book-
$* html book-
$*.xml
51 sed
-i
'' -e
's/xmlns:fo[^ ]*//g' book-
$*/*.html
52 -ls book-
$*/*.html | xargs
-n
1 tidy
-utf8
-m
-i
-q
55 $(foreach l
,$(LANGS
),book-
$(l
)/default.css
): book-
%/default.css
: book.css
57 rsync book.css book-
$*/default.css
59 $(foreach l
,$(LANGS
),book-
$(l
).html
): book-
%.html
: book-
%.xml
60 pandoc
-s
-f docbook
-t html5
-o
$@
$^
62 $(foreach l
,$(LANGS
),book-
$(l
).pdf
): book-
%.pdf
: book-
%.xml
63 pandoc
-s
-f docbook
-o
$@
--pdf-engine
=xelatex
$^
65 book-ru.pdf
: book-ru.xml
66 pandoc
-s
-f docbook
-o
$@
--pdf-engine xelatex
-V mainfont
='DejaVuSansMono' $^
68 book-uk.pdf
: book-uk.xml
69 pandoc
-s
-f docbook
-o
$@
--pdf-engine xelatex
-V mainfont
='DejaVuSansMono' $^
71 book-ko.pdf
: book-ko.xml
72 pandoc
-s
-f docbook
-o
$@
--pdf-engine xelatex
-V CJKmainfont
='WenQuanYi Micro Hei Mono' $^
74 book-zh_cn.pdf
: book-zh_cn.xml
75 pandoc
-s
-f docbook
-o
$@
--pdf-engine xelatex
-V CJKmainfont
='WenQuanYi Micro Hei Mono' $^
77 book-zh_tw.pdf
: book-zh_tw.xml
78 pandoc
-s
-f docbook
-o
$@
--pdf-engine xelatex
-V CJKmainfont
='WenQuanYi Micro Hei Mono' $^
80 $(foreach l
,$(LANGS
),book-
$(l
).epub
): book-
%.epub
: book-
%.xml
81 pandoc
-s
-f docbook
-o
$@
$^
84 -rm -rf
$(foreach l
,$(LANGS
),book-
$(l
).pdf book-
$(l
).xml book-
$(l
).html book-
$(l
)) \
85 *.fo
*.log
*.out
*.aux conf