]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix translation infrastructure
authorJohn Mandereau <john.mandereau@gmail.com>
Mon, 3 Sep 2007 13:52:28 +0000 (15:52 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Mon, 3 Sep 2007 13:52:28 +0000 (15:52 +0200)
The fixes in html-gettext are very ugly, but I'm sick and tired of
fuzzing with regular expressions for cheating with node names.  I'm
not sure all this dirty trickery works, I'm going to contact Texinfo
developers for feature requests, so we can get rid of this mess of
Python and Gettext.

buildscripts/html-gettext.py
buildscripts/texi-gettext.py

index 702b1872c33138c5617e4e5c5b8186e2107674c3..65efe8f28396637b75ffd2f2fea7655632205066 100644 (file)
@@ -36,10 +36,13 @@ html2texi = {'command': (re.compile (r'<samp><span class="command">(.*?)</span><
 texi2html = {'command': (re.compile (r'@command{(.*?)}'), r'<samp><span class="command">\1</span></samp>'),
             'code': (re.compile (r'@code{(.*?)}'), r'<code>\1</code>')
             }
+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():
@@ -74,8 +77,8 @@ def h_gettext (m):
        return '<h' + m.group(1) + m.group(2) + '>' + s +\
               m.group(4) + _(m.group(5)) + '</h' + m.group(1) + '>'
 
-def rglos_gettext (m):
-       return '<a href="../music-glossary/' + m.group(1) + '">' + _(m.group(2)) + '</a>'
+def crossmanual_ref_gettext (m):
+       return '<a href="' + m.group(1) + '">' + _(m.group(2)) + '</a>'
 
 for filename in args[3:]:
        f = open (filename, 'r')
@@ -84,9 +87,11 @@ for filename in args[3:]:
        page = re.sub (r'<link rel="(up|prev|next)" (.*?) title="([^"]*?)">', link_gettext, page)
        page = re.sub (r'<title>([^<]*?) - ([^<]*?)</title>', title_gettext, page)
        # ugh
-       page = re.sub (r'<a ((?:rel="\w+")? ?(?:accesskey="[^"]+?")? ?(?:name=".*?")? ?)(href="[^"]+?">)(<code>)?(Appendix )?([A-Z\d.]+ |)(.+?)(?(3)</code>)</a>:?', a_href_gettext, page)
+       page = re.sub (r'(?ms)<a ((?:rel="\w+")? ?(?:accesskey="[^"]+?")? ?(?:name=".*?")? ?)(href=".+?">)(<code>)?(Appendix )?([A-Z\d.]+ |)(.+?)(?(3)</code>)</a>:?', a_href_gettext, page)
        page = re.sub (r'<h(\d)( class="\w+"|)>(Appendix |)([A-Z\d.]+ |)?([^<]+)</h\1>', h_gettext, page)
-       page = re.sub (r'<a href="../music-glossary/(.+?)">(.+?)</a>', rglos_gettext, page)
+       page = re.sub (r'<a href="(\.\./(?:music-glossary|lilypond-program/)?(?:.+?))">(.+?)</a>', crossmanual_ref_gettext, page)
+       # this is necessary for entries not translated by a_href_gettext
+       page = re.sub (r'<a href="(.+?)">(.+?)</a>', crossmanual_ref_gettext, page)
        for w in ('Next:', 'Previous:', 'Up:'):
                page = re.sub (w, _(w), page)
        page = langdefs.LANGDICT[lang].html_filter (page)
index 00807407b0050db8e6adf59474b3672d0cb47582..2c993526660c9d7e0eef033237b84da92f20ccf8 100644 (file)
@@ -32,7 +32,7 @@ _doc = t.gettext
 
 include_re = re.compile (r'@include ((?!lily-).*?)\.texi$', re.M)
 whitespaces = re.compile (r'\s+')
-ref_re = re.compile (r'(?ms)@(rglos|ref)(\{)(.*?)(\})')
+ref_re = re.compile (r'(?ms)@(rglos|ruser|rprogram|ref)(\{)(.*?)(\})')
 node_section_re = re.compile (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)( )(.*?)(\n)')
 menu_entry_re = re.compile (r'\* (.*?)::')