From 3c08f91969cc562bb9aa354e2b9f4da7f0715260 Mon Sep 17 00:00:00 2001 From: John Mandereau Date: Sun, 24 Jun 2007 13:54:26 +0200 Subject: [PATCH] Make PDF manual in all languages really working --- buildscripts/mass-link.py | 38 ++++++++++++++++++ buildscripts/texi-gettext.py | 77 ++++++++++++++++++++++++++++++++++-- make/doclang-targets.make | 21 +++++----- 3 files changed, 122 insertions(+), 14 deletions(-) create mode 100644 buildscripts/mass-link.py diff --git a/buildscripts/mass-link.py b/buildscripts/mass-link.py new file mode 100644 index 0000000000..1f0ff074c6 --- /dev/null +++ b/buildscripts/mass-link.py @@ -0,0 +1,38 @@ +#!@PYTHON@ +# mass-link.py + +# USAGE: mass-link.py symbolic | hard SOURCEDIR DESTDIR FILES +# +# create hard or symbolic links to SOURCEDIR/FILES in DESTDIR +# +# shell-wildcard expansion is performed on FILES. + +print "mass_link.py" + +import sys +import os +import glob + +link_type, source_dir, dest_dir = sys.argv[1:4] +files = sys.argv[4:] + +if link_type == 'symbolic': + link = os.symlink +elif link_type == 'hard': + link = os.link +else: + sys.stderr.write(sys.argv[0] + ': ' + link_type + ": wrong argument, expected 'symbolic' or 'hard'\n") + sys.exit (1) + +sourcefiles = [] +for pattern in files: + sourcefiles += (glob.glob (os.path.join (source_dir, pattern))) + +destfiles = map (lambda f: os.path.join (dest_dir, os.path.basename (f)), sourcefiles) + +def force_link (src,dest): + if os.path.exists (dest): + os.system ('rm -rf ' + dest) + link (src, dest) + +map (force_link, sourcefiles, destfiles) diff --git a/buildscripts/texi-gettext.py b/buildscripts/texi-gettext.py index 7dd751eca4..dcbcded41b 100644 --- a/buildscripts/texi-gettext.py +++ b/buildscripts/texi-gettext.py @@ -1,4 +1,5 @@ #!@PYTHON@ +# -*- coding: utf-8 -*- # texi-gettext.py # USAGE: texi-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES @@ -7,6 +8,8 @@ # rather than be overwritten # +print "texi_gettext.py" + import sys import re import os @@ -30,20 +33,88 @@ _doc = t.gettext include_re = re.compile (r'@include (.*?)$', re.M) +# Why not use recode? +# - well, it would add one more dependency... +accents2texi = ( + ("á", "@'a"), + ("à", "@`a"), + ("â", "@^a"), + ("ä", "@\"a"), + ("é", "@'e"), + ("è", "@`e"), + ("ê", "@^e"), + ("ë", "@\"e"), + ("ó", "@'o"), + ("ò", "@`o"), + ("ô", "@^o"), + ("ö", "@\"o"), + ("ú", "@'u"), + ("ù", "@`u"), + ("û", "@^u"), + ("ü", "@\"u"), + ("ç", "@,{c}"), + ("À", "@`A"), + ("Á", "@'A"), + ("Â", "@^A"), + ("Ä", "@\"A"), + ("É", "@'E"), + ("È", "@`E"), + ("Ê", "@^E"), + ("Ë", "@\"E"), + ("Ó", "@'O"), + ("Ò", "@`O"), + ("Ô", "@^O"), + ("Ö", "@\"O"), + ("Ú ", "@'U"), + ("Ù", "@`U"), + ("Û", "@^U"), + ("Ü", "@\"U"), + ("Ç", "@,{C}"), + ("Í", "@'{@dotless{i}}"), + ("ì", "@`{@dotless{i}}"), + ("î", "@^{@dotless{i}}"), + ("ï", "@\"{@dotless{i}}"), + ("Í", "@'I"), + ("Ì", "@`I"), + ("Î", "@^I"), + ("Ï", "@\"I"), + ("œ", "@oe{}"), + ("Œ", "@OE{}"), + ("æ", "@ae{}"), + ("Æ", "@AE{}"), + ("¡", "@exclamdown{}"), + ("¿", "@questiondown{}"), + ("ø", "@o{}"), + ("Ø", "@O{}"), + ("ß", "@ss{}"), + ("ł", "@l{}"), + ("Ł", "@L{}"), + ("å", "@aa{}"), + ("Å", "@AA{}")) + + def title_gettext (m): return '@' + m.group (1) + m.group (2) + _doc (m.group (3)) + m.group (4) +def menu_entry_gettext (m): + return '* ' + _doc (m.group (1)) + '::' + 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 = re.sub (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)( )(.*?)(\n)', title_gettext, page) + page = re.sub (r'(?L)@(rglos|ref)(\{)(.*?)(\})', title_gettext, page) + page = re.sub (r'\* (.*?)::', menu_entry_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') + for (u_char, texiaccent_char) in accents2texi: + page = page.replace (u_char, texiaccent_char) + p = os.path.join (outdir, filename) + f = open (p, 'w') f.write (page) f.close () dir = os.path.dirname (filename) @@ -54,5 +125,3 @@ well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", '') 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 13c32dab1f..1b21da230b 100644 --- a/make/doclang-targets.make +++ b/make/doclang-targets.make @@ -14,7 +14,7 @@ $(outdir)/lilypond.nexi: $(ITELY_FILES) $(ITEXI_FILES) MAKEINFO = LANG=$(ISOLANG) $(MAKEINFO_PROGRAM) --force -$(outdir)/lilypond/index.html: png-ln $(outdir)/lilypond.nexi doc-po +$(outdir)/lilypond/index.html: $(outdir)/lilypond.nexi user-ln 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) @@ -24,23 +24,24 @@ $(outdir)/lilypond/index.html: png-ln $(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 $< -$(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) $(