]> pere.pagekite.me Git - text-destroy-surveillance.git/commitdiff
Improve book layout and set up for translation.
authorPetter Reinholdtsen <pere@hungry.com>
Sun, 6 Sep 2020 09:40:06 +0000 (11:40 +0200)
committerPetter Reinholdtsen <pere@hungry.com>
Sun, 6 Sep 2020 09:40:06 +0000 (11:40 +0200)
Makefile
pdf.xsl [new file with mode: 0644]
po4a.cfg [new file with mode: 0644]

index c0d474192576f5150cfa3de53fd3128caa4be19d..a84406a63ada4e0c709a0742ba09bb2242aaa396 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,8 @@ DBLATEX_OPTS = \
   -P double.sided=1 \
   -P doc.collab.show=0 \
   -P latex.output.revhistory=0 \
-  -P draft.mode=yes -Pdraft.watermark=1
+  -P draft.mode=yes -Pdraft.watermark=1 \
+  -p pdf.xsl
 
 all: $(GENERATED)
 
@@ -32,9 +33,24 @@ $(SOURCE).pdf: complete-book.xml Makefile
 $(SOURCE).xml: $(SOURCE).rst Makefile
        pandoc -s -o $@ $(PANDOC_OPTS) $(SOURCE).rst
 
+po/$(SOURCE).pot: complete-book.xml
+       po4a-gettextize -f docbook -m complete-book.xml \
+       -M UTF-8 -L UTF-8 \
+       --package-name "How to Destroy Surveillance Capitalism" \
+       --copyright-holder "Cory Doctorow" \
+       --package-version "n/a" \
+       | sed 's/CHARSET/UTF-8/' > $@.new && mv $@.new $@
+po/$(SOURCE).%.po: po/$(SOURCE).pot
+       po4a --no-translations --msgmerge-opt --no-location po4a.cfg
+
+$(SOURCE).nb.xml: po/$(SOURCE).nb.po complete-book.xml
+       po4a --translate-only $(SOURCE).nb.xml po4a.cfg
+$(SOURCE).nb.pdf: $(SOURCE).nb.xml Makefile
+       dblatex $(DBLATEX_OPTS) $(SOURCE).nb.xml -o $@
+
 XMLLINTOPTS = --nonet --noout  --xinclude --postvalid 
 lint: book.xml
        xmllint $(XMLLINTOPTS) $^
 
 clean:
-       $(RM) $(GENERATED) complete-book.xml
+       $(RM) *~ $(GENERATED) complete-book.xml
diff --git a/pdf.xsl b/pdf.xsl
new file mode 100644 (file)
index 0000000..86fc238
--- /dev/null
+++ b/pdf.xsl
@@ -0,0 +1,30 @@
+<?xml version='1.0' encoding="iso-8859-1"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
+  <xsl:param name="latex.class.book">book</xsl:param>
+  <xsl:param name="latex.class.options">a4paper,openright,twoside</xsl:param>
+
+  <!-- insert a few latex tricks at the top of the .tex document -->
+  <xsl:param name="latex.begindocument">
+    <xsl:text>% start of latex.begindocument
+
+% Trick to avoid many words sticking out of the right margin of the text.
+\sloppy
+
+% The microtype package provides the ability to micromanage your
+% typography. When invoked without any options it does some nice things
+% like protruding punctuation over the edge of the right margin to make
+% the margin appear smoother. Basically it makes your book look more
+% professional with very little effort. It also has a ton of options if
+% you want to micromanage even more.
+\usepackage{microtype}
+
+% Make URLs in footnotes smaller to fit the long URLs
+\usepackage{relsize}
+\usepackage{hyperref}
+\renewcommand*{\UrlFont}{\ttfamily\relsize{-2}}
+
+\begin{document}
+% end of latex.begindocument
+    </xsl:text>
+  </xsl:param>
+</xsl:stylesheet>
diff --git a/po4a.cfg b/po4a.cfg
new file mode 100644 (file)
index 0000000..35d28b7
--- /dev/null
+++ b/po4a.cfg
@@ -0,0 +1,4 @@
+[po_directory] po
+
+[type: docbook] complete-book.xml $lang:$lang.xml \
+       opt:"-M UTF-8 -k 0" opt_nb:"-L UTF-8"