--- /dev/null
+#!@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")
-# 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)
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)
#$(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