]> git.donarmstrong.com Git - lilypond.git/commitdiff
Make PDF manual in all languages really working
authorJohn Mandereau <john.mandereau@gmail.com>
Sun, 24 Jun 2007 11:54:26 +0000 (13:54 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Sun, 24 Jun 2007 11:54:26 +0000 (13:54 +0200)
buildscripts/mass-link.py [new file with mode: 0644]
buildscripts/texi-gettext.py
make/doclang-targets.make

diff --git a/buildscripts/mass-link.py b/buildscripts/mass-link.py
new file mode 100644 (file)
index 0000000..1f0ff07
--- /dev/null
@@ -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)
index 7dd751eca413993be0388e612bb79610b0b3eceb..dcbcded41b4c82ac784ad6542aa8d2ef6aa55742 100644 (file)
@@ -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")
index 13c32dab1f452c51b7e7a014b48a52d376e001c8..1b21da230b9c261284c89158b3a4cc95e19a1c18 100644 (file)
@@ -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) $(<F)
+$(outdir)/%.pdf: $(outdir)/%.texi user-ln doc-po
+       $(PYTHON) $(buildscript-dir)/texi-gettext.py $(buildscript-dir) $(top-build-dir)/Documentation/po/$(outdir) $(ISOLANG) $<
+       cp $< $(<)~
+       cd $(outdir); texi2pdf --batch $(TEXINFO_PAPERSIZE_OPTION) $(<F)
 
-local-WWW: $(outdir)/lilypond/index.html $(outdir)/lilypond.pdf lang-merge
-
-lang-merge: $(outdir)/lilypond/index.html $(outdir)/lilypond.pdf
+local-WWW: $(outdir)/lilypond.pdf $(outdir)/lilypond/index.html
        $(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
 
 # makeinfo is broken, it MUST have PNGs in output dir
-# strangely, this is not true for ly PNGs
 # symlinking PNGs...
-png-ln:
+# lilypond-book -I flag seems broken too, and texi2pdf -I flag confuses
+# pdfetex with .aux and other files from English manual
+# symlinking lily-*...
+user-ln:
        mkdir -p $(outdir)/lilypond
-       cd $(outdir) && $(foreach i, $(LINKED_PNGS), ln -sf ../$(depth)/Documentation/user/$(i) $(i) &&) true
+       $(PYTHON) $(buildscript-dir)/mass-link.py symbolic $(top-build-dir)/Documentation/user/$(outdir) $(outdir) 'lily-*.pdf' 'lily-*.tex' 'lily-*.texi' 'lily-*.ly' 'lily-*.txt' 'lily-*.png' 'henle-flat-gray.*' 'baer-flat-gray.*' 'lily-flat-bw.*'
        cd $(outdir)/lilypond && $(foreach i, $(LINKED_PNGS), ln -sf ../../$(depth)/Documentation/user/$(i) $(i) &&) true
 
 local-WWW-clean: deep-WWW-clean