bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enhancement: automatically translate tagline


From: Simon Albrecht
Subject: Re: Enhancement: automatically translate tagline
Date: Mon, 16 Mar 2015 01:10:47 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

Thanks for elaborating, Harm. That’s some elegant coding with which I couldn’t have come up :-)

Am 15.03.2015 um 19:22 schrieb Thomas Morley:

[snip]

\version "2.19.16"

%% Please note, \language has to be declared before 'used-language'
%% is done or included, (if stored elsewhere)
\language "deutsch"
%\language "english"
%% if no tagline for a language is defined, default-english will be printed
%\language "catalan"

%% TODO: find better method to detect which language is actually used
#(define used-language
  (car
    (find
      (lambda (e) (eq? (cdr e) (ly:parser-lookup parser 'pitchnames)))
      language-pitch-names)))
I imagine that a generic solution worth being included in the code base would require this definition to be made through the \language command itself.

englishTaglineText = #(format #f
"Music typeset using LilyPond ~a~awww.lilypond.org <http://awww.lilypond.org>"
                        (lilypond-version)
                        (ly:wide-char->utf-8 #x2014) ;; 2014 = em dash.
                        )
germanTaglineText = #(format #f
"Noten gesetzt mit LilyPond ~a ~a www.lilypond.org <http://www.lilypond.org>"
                       (lilypond-version)
                       (ly:wide-char->utf-8 #x2013) ;;2013 = en dash.
                       )

#(define taglines
`(
  (deutsch . ,germanTaglineText)
  (english . ,englishTaglineText)
 ))

#(define-markup-command (format-tagline layout props text) (markup?)
  (interpret-markup layout props
    #{
      \markup {
        \italic
        \pad-to-box #'(0 . 0) #'(0 . 3)
        {
          \with-url #"http://lilypond.org/";
          $text
        }
      }
    #}))

#(define used-tagline
  (markup #:format-tagline
   (let ((tagl (assoc-get used-language taglines)))
     (if tagl
         tagl
         (assoc-get 'english taglines)))))

\header {
  tagline = #used-tagline
}
In the attachment, I made an additional function, getTagline, to have the user select a tagline (somehow, it didn’t work with define in line 57, only if tagline was already defined and then set! applied – why?). (There’s certainly room for improvements in the coding.)

Thanks
Simon

Attachment: tagline-b.ly
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]