X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fhtml-gettext.py;h=aaa8888a3fdac88bcc92052a88a52aa34d17c0ab;hb=8e48439b49807222074336a77e1b9873fd8e767f;hp=d6a06c901c83deed52849c34a52db9ae8cea1087;hpb=b4c6eeb732dba1ff6f3d700e94f6e4d839600ff7;p=lilypond.git
diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py
index d6a06c901c..aaa8888a3f 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,82 +11,109 @@ 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 = ((' -- ', ' – '),
- (' --- ', ' — '))
-html2texi = {'command': (re.compile (r'(.*?)'), r'@command{\1}'),
- 'code': (re.compile (r'(.*?)
'), r'@code{\1}')
- }
-texi2html = {'command': (re.compile (r'@command{(.*?)}'), r'\1'),
- 'code': (re.compile (r'@code{(.*?)}'), r'\1
')
- }
+ (' --- ', ' — '),
+ ("'", '’'))
+html2texi = {'command':
+ (re.compile (r'(.*?)'),
+ r'@command{\1}'),
+ 'code':
+ (re.compile (r'(.*?)
'),
+ r'@code{\1}')
+ }
+texi2html = {'command':
+ (re.compile (r'@command{(.*?)}'),
+ r'\1'),
+ 'code':
+ (re.compile (r'@code{(.*?)}'),
+ r'\1
')
+ }
+whitespaces = re.compile (r'\s+')
+
def _ (s):
- if not s:
- return ''
- for c in html_codes:
- s = s.replace (c[1], c[0])
- for u in html2texi.values():
- s = u[0].sub (u[1], s)
- s = my_gettext (s)
- for u in texi2html.values():
- s = u[0].sub (u[1], s)
- for c in html_codes:
- s = s.replace (c[0], c[1])
- return s
+ if not s:
+ return ''
+ s = whitespaces.sub (' ', s)
+ for c in html_codes:
+ s = s.replace (c[1], c[0])
+ for u in html2texi.values():
+ s = u[0].sub (u[1], s)
+ s = my_gettext (s)
+ for u in texi2html.values():
+ s = u[0].sub (u[1], s)
+ for c in html_codes:
+ s = s.replace (c[0], c[1])
+ return s
+
+link_re = re.compile (r'')
def link_gettext (m):
- return ''
+ return ''
-def title_gettext (m):
- return '
|))\
+(Appendix |)([A-Z0-9.]+ | (?:<){1,2} | [^:<]+?: | |)\
+(.+?)(
| (?:>){1,2} | |):?')
def a_href_gettext (m):
- s = ''
- if m.group(0)[-1] == ':':
- s = double_punct_char_separator + ':'
- t = ''
- if m.lastindex == 7:
- t = m.group(7)
- return '' + s
+ s = ''
+ if m.group(0)[-1] == ':':
+ s = double_punct_char_separator + ':'
+ t = ''
+ if m.group (2):
+ t = _ (m.group (2))
+ return '' + s
+
+h_re = re.compile (r')?(Appendix )?([A-Z\d.]+ |)(.+?)(?(3)
):?', a_href_gettext, page)
- page = re.sub (r'