X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Fhtml-gettext.py;h=702b1872c33138c5617e4e5c5b8186e2107674c3;hb=57b8f8c8f6563c15f16d346bc4e1f667b246c7b4;hp=3f401382ae23cf3c54c8e867a00fb1f270fc96e4;hpb=8f5cd22af76fcb5c77853a5ede8b94ebef97caef;p=lilypond.git diff --git a/buildscripts/html-gettext.py b/buildscripts/html-gettext.py index 3f401382ae..702b1872c3 100644 --- a/buildscripts/html-gettext.py +++ b/buildscripts/html-gettext.py @@ -25,18 +25,28 @@ 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 = ((' -- ', ' – '), (' --- ', ' — ')) +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') + } 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 @@ -48,15 +58,24 @@ def title_gettext (m): return '' + _(m.group(1)) + ' - ' + m.group(2) + '' def a_href_gettext (m): - if m.group(6) == ':': + s = '' + if m.group(0)[-1] == ':': s = double_punct_char_separator + ':' - elif m.group(6) == None: - s = '' - return '' + s + t = '' + if m.lastindex == 7: + t = m.group(7) + return '' + s def h_gettext (m): - return '' + \ - m.group(3) + _(m.group(4)) + '' + if m.group (3): + s = _(m.group(3)) + else: + s= '' + return '' + s +\ + m.group(4) + _(m.group(5)) + '' + +def rglos_gettext (m): + return '' + _(m.group(2)) + '' for filename in args[3:]: f = open (filename, 'r') @@ -64,10 +83,13 @@ for filename in args[3:]: f.close() page = re.sub (r'', link_gettext, page) page = re.sub (r'([^<]*?) - ([^<]*?)', title_gettext, page) - page = re.sub (r')((?:|)(?:[\d.]+ |))([^<]+)(|)(:)?', a_href_gettext, page) - page = re.sub (r'([\d.]+ |)?([^<]+)', h_gettext, page) + # ugh + page = re.sub (r')()?(Appendix )?([A-Z\d.]+ |)(.+?)(?(3)):?', a_href_gettext, page) + page = re.sub (r'(Appendix |)([A-Z\d.]+ |)?([^<]+)', h_gettext, page) + page = re.sub (r'(.+?)', rglos_gettext, page) for w in ('Next:', 'Previous:', 'Up:'): page = re.sub (w, _(w), page) + page = langdefs.LANGDICT[lang].html_filter (page) f = open (os.path.join (outdir, filename), 'w') f.write (page) f.close ()