X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fhtml-gettext.py;h=65efe8f28396637b75ffd2f2fea7655632205066;hb=29b060250128c577ab8f3cc4837d35b4ace625bf;hp=97f8e5f6f66fbc806490d01a12625800cb3f34e9;hpb=e0fe5d924082970ba7280ccb148eadababf00983;p=lilypond.git
diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py
index 97f8e5f6f6..65efe8f283 100644
--- a/buildscripts/html-gettext.py
+++ b/buildscripts/html-gettext.py
@@ -1,45 +1,58 @@
#!@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':' ', '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']
-
-t = gettext.translation('lilypond-doc', args[0], [args[1]])
-_ = t.gettext
+sys.path.append (buildscript_dir)
+import langdefs
+
+double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep
+t = gettext.translation('lilypond-doc', localedir, [lang])
+my_gettext = t.gettext
+
+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
')
+ }
+whitespaces = re.compile (r'\s+')
+
+
+def _ (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
def link_gettext (m):
return ''
@@ -48,26 +61,40 @@ def title_gettext (m):
return '
)?(Appendix )?([A-Z\d.]+ |)(.+?)(?(3)
):?', a_href_gettext, page)
+ page = re.sub (r'