From: John Mandereau Date: Wed, 10 Dec 2008 19:49:19 +0000 (+0100) Subject: Add lilypond-book fragment option 'nogettext' X-Git-Tag: release/2.12.0-1~40^2~2^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b8e89fb1d3d059d8ac16ee963b9cc7e69c33a28d;p=lilypond.git Add lilypond-book fragment option 'nogettext' --- diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely index f35bcb1022..0eaae36f64 100644 --- a/Documentation/user/lilypond-book.itely +++ b/Documentation/user/lilypond-book.itely @@ -674,6 +674,13 @@ will be printed with a verbatim block like f2 e @end example +@noindent +If you would like to translate comments and variable names in verbatim +output but not in the sources, you may set the environment variable +@code{LYDOC_LOCALEDIR} to a directory path; the directory should +contain a tree of @file{.mo} message catalogs with @code{lilypond-doc} +as a domain. + @item addversion (Only for Texinfo output.) Prepend line @code{\version @@w@{"@@version@{@}"@}} to @code{verbatim} output. @@ -740,6 +747,10 @@ Texinfo document as @code{@@lydoctitle @var{text}}. The same remark about @code{texidoc} processing with localized languages also applies to @code{doctitle}. +@item nogettext +(Only for Texinfo output.) Do not translate comments and variable +names in the snippet quoted verbatim. + @item printfilename If a LilyPond input file is included with @code{\lilypondfile}, print the file name right before the music snippet. For HTML output, this diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 560f675de2..655ea9888e 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -253,6 +253,7 @@ LAYOUT = 'layout' LINE_WIDTH = 'line-width' LILYQUOTE = 'lilyquote' NOFRAGMENT = 'nofragment' +NOGETTEXT = 'nogettext' NOINDENT = 'noindent' NOQUOTE = 'noquote' NORAGGED_RIGHT = 'noragged-right' @@ -572,6 +573,7 @@ simple_options = [ EXAMPLEINDENT, FRAGMENT, NOFRAGMENT, + NOGETTEXT, NOINDENT, PRINTFILENAME, DOCTITLE, @@ -993,7 +995,10 @@ class LilypondSnippet (Snippet): self.do_options (os, self.type) def verb_ly (self): - return verb_ly_gettext (self.substring ('code')) + if NOGETTEXT in self.option_dict: + return self.substring ('code') + else: + return verb_ly_gettext (self.substring ('code')) def ly (self): contents = self.substring ('code') @@ -1211,7 +1216,8 @@ class LilypondSnippet (Snippet): file (path + '.txt', 'w').write ('image of music') def relevant_contents (self, ly): - return re.sub (r'\\(version|sourcefileline|sourcefilename)[^\n]*\n', '', ly) + return re.sub (r'\\(version|sourcefileline|sourcefilename)[^\n]*\n|' + + NOGETTEXT + '[,\]]', '', ly) def link_all_output_files (self, output_dir, output_dir_files, destination): existing, missing = self.all_output_files (output_dir, output_dir_files)