From: John Mandereau Date: Sun, 17 Jun 2007 21:21:35 +0000 (+0200) Subject: Add localized PDF user manual support X-Git-Tag: release/2.11.28-1~82 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=eb1c49112df603bb1b885249d24870c462d8e1ee;p=lilypond.git Add localized PDF user manual support --- diff --git a/buildscripts/texi-gettext.py b/buildscripts/texi-gettext.py new file mode 100644 index 0000000000..7dd751eca4 --- /dev/null +++ b/buildscripts/texi-gettext.py @@ -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") diff --git a/make/doclang-targets.make b/make/doclang-targets.make index a259350175..13c32dab1f 100644 --- a/make/doclang-targets.make +++ b/make/doclang-targets.make @@ -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) $(