]> git.donarmstrong.com Git - lilypond.git/commitdiff
Docs: add support for context names translation in ly snippets
authorJohn Mandereau <john.mandereau@gmail.com>
Sun, 9 Nov 2008 11:26:53 +0000 (12:26 +0100)
committerJohn Mandereau <john.mandereau@gmail.com>
Sun, 9 Nov 2008 11:26:53 +0000 (12:26 +0100)
buildscripts/texi-langutils.py
scripts/lilypond-book.py

index 7486ebee01c5ce652dbdd0ad3d7d9228348c0c46..37de5cc4193475aafdba0c6396e8ac1e30e7ed04 100644 (file)
@@ -61,7 +61,7 @@ texinfo_with_menus_re = re.compile (r"^(\*) +([^:\n]+)::.*?$|^@(include|menu|end
 
 texinfo_re = re.compile (r"^@(include|node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading) *(.+?)$|@(rglos){(.+?)}", re.M)
 
-ly_string_re = re.compile (r'^([a-zA-Z]+)[\t ]*=|%+[\t ]*(.*)$')
+ly_string_re = re.compile (r'^([a-zA-Z]+)[\t ]*=|%+[\t ]*(.*)$|\\(?:new|context)\s+(?:[a-zA-Z]*?(?:Staff(?:Group)?|Voice|FiguredBass|FretBoards|Names|Devnull))\s+=\s+"?([a-zA-Z]+)"?\s+')
 verbatim_ly_re = re.compile (r'@lilypond\[.*?verbatim')
 
 def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, output_file=None, scan_ly=False):
@@ -83,7 +83,7 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, outpu
                 elif lines[i].startswith ('@end lilypond'):
                     in_verb_ly_block = False
                 elif in_verb_ly_block:
-                    for (var, comment) in ly_string_re.findall (lines[i]):
+                    for (var, comment, context_id) in ly_string_re.findall (lines[i]):
                         if var:
                             output_file.write ('# ' + printedfilename + ':' + \
                                                str (i + 1) + ' (variable)\n_(r"' + var + '")\n')
@@ -91,6 +91,10 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, outpu
                             output_file.write ('# ' + printedfilename + ':' + \
                                                str (i + 1) + ' (comment)\n_(r"' + \
                                                comment.replace ('"', '\\"') + '")\n')
+                        elif context_id:
+                            output_file.write ('# ' + printedfilename + ':' + \
+                                               str (i + 1) + ' (context id)\n_(r"' + \
+                                               context_id + '")\n')
 
         # process Texinfo node names and section titles
         if write_skeleton:
index be9fef694a5d81049d92799b4ecb39d18498fbc9..b8c765d3fb0b74799d2269f922a4bcbf2e3f43a4 100644 (file)
@@ -840,6 +840,8 @@ def verbatim_html (s):
 
 ly_var_def_re = re.compile (r'^([a-zA-Z]+)[\t ]*=', re.M)
 ly_comment_re = re.compile (r'(%+[\t ]*)(.*)$', re.M)
+ly_context_id_re = re.compile ('\\\\(?:new|context)\\s+(?:[a-zA-Z]*?(?:Staff\
+(?:Group)?|Voice|FiguredBass|FretBoards|Names|Devnull))\\s+=\\s+"?([a-zA-Z]+)"?\\s+')
 
 def ly_comment_gettext (t, m):
     return m.group (1) + t (m.group (2))
@@ -858,6 +860,10 @@ def verb_ly_gettext (s):
         s = re.sub (r"(?m)(^|[' \\#])%s([^a-zA-Z])" % v,
                     "\\1" + t (v) + "\\2",
                     s)
+    for id in ly_context_id_re.findall (s):
+        s = re.sub (r'(\s+|")%s(\s+|")' % id,
+                    "\\1" + t (id) + "\\2",
+                    s)
     return s
 
 texinfo_lang_re = re.compile ('(?m)^@documentlanguage (.*?)( |$)')