]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add localized PDF user manual support
authorJohn Mandereau <john.mandereau@gmail.com>
Sun, 17 Jun 2007 21:21:35 +0000 (23:21 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Sun, 17 Jun 2007 21:21:35 +0000 (23:21 +0200)
buildscripts/texi-gettext.py [new file with mode: 0644]
make/doclang-targets.make

diff --git a/buildscripts/texi-gettext.py b/buildscripts/texi-gettext.py
new file mode 100644 (file)
index 0000000..7dd751e
--- /dev/null
@@ -0,0 +1,58 @@
+#!@PYTHON@
+# texi-gettext.py
+
+# USAGE:  texi-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES
+#
+# -o OUTDIR specifies that output files should be written in OUTDIR
+#    rather than be overwritten
+#
+
+import sys
+import re
+import os
+import getopt
+import gettext
+
+optlist, args = getopt.getopt(sys.argv[1:],'o:')
+buildscript_dir, localedir, lang = args[0:3]
+
+outdir = '.'
+for x in optlist:
+       if x[0] == '-o':
+               outdir = x[1]
+
+sys.path.append (buildscript_dir)
+import langdefs
+
+double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep
+t = gettext.translation('lilypond-doc', localedir, [lang])
+_doc = t.gettext
+
+include_re = re.compile (r'@include (.*?)$', re.M)
+
+def title_gettext (m):
+       return '@' + m.group (1) + m.group (2) + _doc (m.group (3)) + m.group (4)
+
+def process_file (filename):
+       print "Processing %s" % filename
+       f = open (filename, 'r')
+       page = f.read ()
+       f.close()
+       page = re.sub (r'(?L)@(rglos|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)(\{| )(.*?)(\}|\n)', title_gettext, page)
+       page = page.replace ("""-- SKELETON FILE --
+When you actually translate this file, please remove these lines as
+well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", '')
+       page = page.replace ('UNTRANSLATED NODE: IGNORE ME', _doc ("This section has not been translated yet; please refer to the manual in English."))
+       f = open (os.path.join (outdir, filename), 'w')
+       f.write (page)
+       f.close ()
+       dir = os.path.dirname (filename)
+       for file in include_re.findall (page):
+               p = os.path.join (dir, file)
+               if os.path.exists (p):
+                       process_file (p)
+
+for filename in args[3:]:
+       process_file (filename)
+
+toto = raw_input ("Press enter to continue")
index a25935017511d63bac5a83658f40074e26fbbf34..13c32dab1f452c51b7e7a014b48a52d376e001c8 100644 (file)
@@ -1,7 +1,9 @@
-# assumes depth and ISOLANG are defined
+# one assumes depth and ISOLANG are defined
 
 OUT_ITEXI_FILES = $(ITELY_FILES:%.itely=$(outdir)/%.itexi)
 
+TEXINFO_PAPERSIZE_OPTION= $(if $(findstring $(PAPERSIZE),a4),,-t @afourpaper)
+
 LILYPOND_BOOK_INCLUDES += \
   -I$(top-src-dir)/Documentation/user \
   -I$(top-build-dir)/Documentation/user/$(outdir)
@@ -12,7 +14,7 @@ $(outdir)/lilypond.nexi: $(ITELY_FILES) $(ITEXI_FILES)
 
 MAKEINFO = LANG=$(ISOLANG) $(MAKEINFO_PROGRAM) --force
 
-$(outdir)/lilypond/index.html: $(outdir)/lilypond.nexi doc-po
+$(outdir)/lilypond/index.html: png-ln $(outdir)/lilypond.nexi doc-po
        mkdir -p $(dir $@)
        -$(MAKEINFO) -I$(outdir) --output=$(outdir)/lilypond --css-include=$(top-src-dir)/Documentation/texinfo.css --html $<
        find $(outdir) -name '*.html' | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/html-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG)
@@ -22,10 +24,14 @@ $(outdir)/lilypond/index.html: $(outdir)/lilypond.nexi doc-po
 #$(outdir)/lilypond.html: $(outdir)/lilypond.nexi
 #      -$(MAKEINFO) -I$(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split --no-headers $< 
 
-local-WWW: png-ln $(outdir)/lilypond/index.html lang-merge
+$(outdir)/%.pdf: $(outdir)/%.texi $(outdir)/lilypond/index.html
+       $(PYTHON) $(buildscript-dir)/texi-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG) $(<)
+       cd $(outdir); texi2pdf -I $(top-build-dir)/Documentation/user/$(outdir) --batch $(TEXINFO_PAPERSIZE_OPTION) $(<F)
+
+local-WWW: $(outdir)/lilypond/index.html $(outdir)/lilypond.pdf lang-merge
 
-lang-merge:
-       $(foreach i, $(shell find $(outdir) -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME'), ln -f $(i) $(i:$(outdir)/%.html=$(depth)/Documentation/user/$(outdir)/%.$(ISOLANG).html) &&) true
+lang-merge: $(outdir)/lilypond/index.html $(outdir)/lilypond.pdf
+       $(foreach i, $(shell find $(outdir) -name '*.html' | xargs grep -L --label="" 'UNTRANSLATED NODE: IGNORE ME'), ln -f $(i) $(i:$(outdir)/%.html=$(depth)/Documentation/user/$(outdir)/%.$(ISOLANG).html) &&) ln -f $(outdir)/lilypond.pdf $(depth)/Documentation/user/$(outdir)/lilypond.$(ISOLANG).pdf && true
 
 LINKED_PNGS = henle-flat-gray.png baer-flat-gray.png lily-flat-bw.png