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
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 xmlto
-m custom-nochunks.xsl html-nochunks
$^
63 # Set SP_ENCODING to avoid "non SGML character" errors.
64 # Can also do SP_ENCODING="UTF-8".
65 $(foreach l
,$(LANGS
),book-
$(l
).pdf
): book-
%.pdf
: book-
%.xml
66 if
[ $* = zh_cn
-o
$* = zh_tw
]; then \
67 if
! [ -f fop-
$*.xsl
]; then wget
-q http
://bestrecords.net
/fop
/fop-
$*.xsl
; fi
; \
68 if
! [ -f fop-
$*.xconf
]; then wget
-q http
://bestrecords.net
/fop
/fop-
$*.xconf
; fi
; \
69 xmlto
-m fop-
$*.xsl
--with-fop
-p
"-c `pwd`/fop-$*.xconf" pdf book-
$*.xml
;\
70 elif
[ $* = vi
] ; then \
71 xsltproc
--encoding utf-8 fop-vi.xsl book-
$*.xml
> book-
$*.fo
; \
72 fop
-c fop-vi.xconf
-fo book-
$*.fo
-pdf book-
$*.pdf
; \
74 SP_ENCODING
="XML" docbook2pdf book-
$*.xml
; \
78 -rm -rf
$(foreach l
,$(LANGS
),book-
$(l
).pdf book-
$(l
).xml book-
$(l
).html book-
$(l
)) \
79 *.fo
*.log
*.out
*.aux conf