]> git.donarmstrong.com Git - lilypond.git/commitdiff
Improve documentation i18n
authorJohn Mandereau <john.mandereau@gmail.com>
Sat, 23 Dec 2006 22:00:17 +0000 (23:00 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 24 Dec 2006 10:07:31 +0000 (11:07 +0100)
  - Documentation/GNUmakefile: get enabled translations from
buildscripts/langdefs.py
  - Documentation/po/GNUmakefile: use $(buildscript-dir)
  - buildscripts/html-gettext.py: use langdefs.py module and fix
regular expressions.
  - buildscripts/texi-langutils.py: add 'Footnotes' to translatable
strings.
  - make/doclang-targets.make: use new html-gettext argument list

Documentation/GNUmakefile
Documentation/po/GNUmakefile
buildscripts/html-gettext.py
buildscripts/texi-langutils.py
make/doclang-targets.make

index 55f08098858a0d0a92d48d4bc06c7a1b54d18afd..37a452a11f1b975c33a484ac18f2b76e1b428572 100644 (file)
@@ -1,7 +1,7 @@
 depth = ..
 
 NAME = documentation
-LANGS = fr # don't enable unpolished or broken translations
+LANGS = $(shell $(PYTHON) $(buildscript-dir)/langdefs.py)
 SUBDIRS=user bibliography pictures topdocs misc po $(LANGS)
 STEPMAKE_TEMPLATES=documentation texinfo tex
 LOCALSTEPMAKE_TEMPLATES=lilypond ly
@@ -39,8 +39,9 @@ new-lang:
        cp fr/GNUmakefile $(ISOLANG)
        cp fr/user/GNUmakefile $(ISOLANG)/user
        sed -i -e 's/ISOLANG *= *fr/ISOLANG = $(ISOLANG)/' $(ISOLANG)/GNUmakefile $(ISOLANG)/user/GNUmakefile
-       $(PYTHON) $(depth)/buildscripts/texi-langutils.py -d $(outdir) -b "UNTRANSLATED NODE: IGNORE ME" -o doc.pot --skeleton --gettext ../user/lilypond.tely
+       $(PYTHON) $(buildscript-dir)/texi-langutils.py -d $(outdir) -b "UNTRANSLATED NODE: IGNORE ME" -o doc.pot --skeleton --gettext ../user/lilypond.tely
        mv $(outdir)/*.*tely $(ISOLANG)/user
        msgmerge -U po/lilypond-doc.pot $(outdir)/doc.pot
        cp po/lilypond-doc.pot po/$(ISOLANG).po
-endif
\ No newline at end of file
+       @echo "***  Please add a language definition for $(ISOLANG) in buildscripts/langdefs.py  ***"
+endif
index 23939296d006e88188dc24fe75a4a8c4b172e3f4..925cb7e5a12612e550d771b1c82d4a9d22db0192 100644 (file)
@@ -14,7 +14,7 @@ messages: $(MO_FILES)
        done
 
 po-update:
-       $(PYTHON) $(depth)/buildscripts/texi-langutils.py -d $(outdir) -o doc.pot --gettext ../$(depth)/Documentation/user/lilypond.tely
+       $(PYTHON) $(buildscript-dir)/texi-langutils.py -d $(outdir) -o doc.pot --gettext ../$(depth)/Documentation/user/lilypond.tely
        msgmerge -U lilypond-doc.pot $(outdir)/doc.pot
        for i in $(CATALOGS); do \
          msgmerge -U $$i.po lilypond-doc.pot; \
index 97f8e5f6f66fbc806490d01a12625800cb3f34e9..3f401382ae23cf3c54c8e867a00fb1f270fc96e4 100644 (file)
@@ -1,45 +1,45 @@
 #!@PYTHON@
 # html-gettext.py
 
-# Usage:  html-gettext.py [-o OUTDIR] LOCALEDIR LANG FILES
+# USAGE:  html-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES
 #
 # -o OUTDIR specifies that output files should be written in OUTDIR
 #    rather than be overwritten
 #
-# LANG
-# LOCALEDIR should contain 'lilypond-doc' message catalogs
-
-
-### DATA
-# Currently, typo_rules[LANG] only defines the HTML-coded space occuring
-# before double punctuation characters (i.e. : ; ? ! ) for LANG
-
-typo_rules = { 'fr':'&nbsp;', 'default':'' }
-
-
-### PROGRAM
 
 import sys
 import re
 import os
-import string
-import gettext
 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]
 
-if args[1] in typo_rules.keys():
-       dbl_punct_char_separator = typo_rules[args[1]]
-else:
-       dbl_punct_char_separator = typo_rules['default']
+sys.path.append (buildscript_dir)
+import langdefs
+
+double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep
+print localedir
+print lang
+t = gettext.translation('lilypond-doc', localedir, [lang])
+my_gettext = t.gettext
+
+html_codes = ((' -- ', ' &ndash; '),
+             (' --- ', ' &mdash; '))
 
-t = gettext.translation('lilypond-doc', args[0], [args[1]])
-_ = t.gettext
+def _ (s):
+       for c in html_codes:
+               s = s.replace (c[1], c[0])
+       s = my_gettext (s)
+       for c in html_codes:
+               s = s.replace (c[0], c[1])
+       return s
 
 def link_gettext (m):
        return '<link rel="' + m.group(1) + '" ' + m.group(2) + ' title="' + _(m.group(3)) + '">'
@@ -48,24 +48,24 @@ def title_gettext (m):
        return '<title>' + _(m.group(1)) + ' - ' + m.group(2) + '</title>'
 
 def a_href_gettext (m):
-       if m.group(4) == ':':
-               s = dbl_punct_char_separator + ':'
-       elif m.group(4) == None:
+       if m.group(6) == ':':
+               s = double_punct_char_separator + ':'
+       elif m.group(6) == None:
                s = ''
-       return '<a ' + (m.group(1) or '') + m.group(2) + _(m.group(3)) + '</a>' + s
+       return '<a ' + (m.group(1) or '') + m.group(2) + m.group(3) + _(m.group(4)) + m.group(5) + '</a>' + s
 
 def h_gettext (m):
-       return '<h' + m.group(1) + ' class="' + m.group(2) + '">' + \
-              (m.group(3) or '') + _(m.group(4)) + '</h' + m.group(1) + '>'
+       return '<h' + m.group(1) + m.group(2) + '>' + \
+              m.group(3) + _(m.group(4)) + '</h' + m.group(1) + '>'
 
-for filename in args[2:]:
+for filename in args[3:]:
        f = open (filename, 'r')
        page = f.read ()
        f.close()
        page = re.sub (r'<link rel="(up|prev|next)" (.*?) title="([^"]*?)">', link_gettext, page)
        page = re.sub (r'<title>([^<]*?) - ([^<]*?)</title>', title_gettext, page)
-       page = re.sub (r'<a ((?:rel="\w+")? ?(?:accesskey="[^"]+?" ?)?)(href="[^"]+?">)([^<]+)</a>(:)?', a_href_gettext, page)
-       page = re.sub (r'<h(\d) class="(\w+)">([\d.]+ )?([^<]+)</h\1>', h_gettext, page)
+       page = re.sub (r'<a ((?:rel="\w+")? ?(?:accesskey="[^"]+?" ?)?)(href="[^"]+?">)((?:<code>|)(?:[\d.]+ |))([^<]+)(</code>|)</a>(:)?', a_href_gettext, page)
+       page = re.sub (r'<h(\d)( class="\w+"|)>([\d.]+ |)?([^<]+)</h\1>', h_gettext, page)
        for w in ('Next:', 'Previous:', 'Up:'):
                page = re.sub (w, _(w), page)
        f = open (os.path.join (outdir, filename), 'w')
index 09737639b7834523bbc14e377e3b355cb7951535..62c87619ddadf9f8a030057fe15db80c4f6a980f 100644 (file)
@@ -86,7 +86,7 @@ if make_gettext:
        node_list = open (node_list_filename, 'w')
        for texi_file in texi_files:
                process_texi (texi_file, intro_blurb, node_blurb, make_skeleton, node_list)
-       for word in ('Up:', 'Next:', 'Previous:', 'Appendix'):
+       for word in ('Up:', 'Next:', 'Previous:', 'Appendix', 'Footnotes'):
                node_list.write ('_("' + word + '")\n')
        node_list.close ()
        os.system ('xgettext -L Python --no-location -o ' + output_file + ' ' + node_list_filename)
index 7547e39ea69177fd4241b1bba42643134389b131..676cbe43e041a352f9a8b1259bcc958876605a6f 100644 (file)
@@ -15,7 +15,7 @@ MAKEINFO = LANG=$(ISOLANG) $(MAKEINFO_PROGRAM) --force
 $(outdir)/lilypond/index.html: $(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) $(top-src-dir)/buildscripts/html-gettext.py $(depth)/Documentation/po/$(outdir) $(ISOLANG)
+       find $(outdir) -name '*.html' | xargs grep -L 'UNTRANSLATED NODE: IGNORE ME' | xargs $(PYTHON) $(buildscript-dir)/html-gettext.py $(buildscript-dir) $(top-src-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 $<