X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fhtml-gettext.py;h=ccfe6937c0316ec354e2116239475338951a719d;hb=a6a4b3fc2009f17a1a48cca0c11bfd3f38645937;hp=3f401382ae23cf3c54c8e867a00fb1f270fc96e4;hpb=8f5cd22af76fcb5c77853a5ede8b94ebef97caef;p=lilypond.git
diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py
index 3f401382ae..ccfe6937c0 100644
--- a/buildscripts/html-gettext.py
+++ b/buildscripts/html-gettext.py
@@ -1,7 +1,7 @@
#!@PYTHON@
# html-gettext.py
-# USAGE: html-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES
+# USAGE: html-gettext.py [-o OUTDIR] LANG FILES
#
# -o OUTDIR specifies that output files should be written in OUTDIR
# rather than be overwritten
@@ -11,63 +11,116 @@ import sys
import re
import os
import getopt
-import gettext
+
+import langdefs
optlist, args = getopt.getopt(sys.argv[1:],'o:')
-buildscript_dir, localedir, lang = args[0:3]
+lang = args[0]
+files = args [1:]
outdir = '.'
for x in optlist:
- if x[0] == '-o':
- outdir = x[1]
-
-sys.path.append (buildscript_dir)
-import langdefs
+ if x[0] == '-o':
+ outdir = x[1]
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
+my_gettext = langdefs.translation[lang]
html_codes = ((' -- ', ' – '),
- (' --- ', ' — '))
+ (' --- ', ' — '),
+ ("'", '’'))
+texi_html_conversion = {
+ 'command': {
+ 'html2texi':
+ (re.compile (r'(?:|)(.*?)(?:
|)'),
+ r'@command{\1}'),
+ 'texi2html':
+ (re.compile (r'@command{(.*?)}'),
+ r'\1
'),
+ },
+ 'code': {
+ 'html2texi':
+ (re.compile (r'(.*?)
'),
+ r'@code{\1}'),
+ 'texi2html':
+ (re.compile (r'@code{(.*?)}'),
+ r'\1
'),
+ },
+ }
+
+whitespaces = re.compile (r'\s+')
+
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
+ if not s:
+ return ''
+ str = whitespaces.sub (' ', s)
+ for c in html_codes:
+ str = str.replace (c[1], c[0])
+ for command in texi_html_conversion:
+ d = texi_html_conversion[command]
+ str = d['html2texi'][0].sub (d['html2texi'][1], str)
+ str = my_gettext (str)
+ str = d['texi2html'][0].sub (d['texi2html'][1], str)
+ for c in html_codes:
+ str = str.replace (c[0], c[1])
+ return str
+
+link_re = re.compile (r'')
def link_gettext (m):
- return ''
+ return ''
-def title_gettext (m):
- return '
)?\
+(?PAppendix )?(?P[A-Z0-9.]+ | (?:<){1,2} | [^>:]+?: | |)\
+(?P(?:|?code>||[^>])+?)(?P(?(code)
|))\
+(?P (?:>){1,2} | |)
:?')
def a_href_gettext (m):
- if m.group(6) == ':':
- s = double_punct_char_separator + ':'
- elif m.group(6) == None:
- s = ''
- return '' + s
+ s = ''
+ if m.group(0)[-1] == ':':
+ s = double_punct_char_separator + ':'
+ t = ''
+ if m.group ('appendix'):
+ t = _ (m.group ('appendix'))
+ return '' + s
+
+h_re = re.compile (r'|)(?:[\d.]+ |))([^<]+)(
|)(:)?', a_href_gettext, page)
- page = re.sub (r'