[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Enhancement: automatically translate tagline
From: |
Thomas Morley |
Subject: |
Re: Enhancement: automatically translate tagline |
Date: |
Sun, 15 Mar 2015 19:22:00 +0100 |
2015-03-15 17:18 GMT+01:00 Simon Albrecht <address@hidden>:
> Hello,
>
> in my stylesheets, I usually include
>
> germanTagline = \markup {
> \italic
> \pad-to-box #'(0 . 0) #'(0 . 3)
> {
> \with-url #"http://lilypond.org/"
> \line {
> #(format #f "Noten gesetzt mit LilyPond ~a ~a www.lilypond.org"
> (lilypond-version)
> (ly:wide-char->utf-8 #x2013) ;;2013 = en dash.
> )
> }
> }
> }
>
> and write
>
> \header {
> tagline = \germanTagline
> }
>
> in the score.
>
> Wouldn’t it be possible to do this automatically on the grounds of the
> \language command?
>
> As another approach one might provide a function which, in \header {},
> allows to write
>
> \Tagline "deutsch" or
> \Tagline "de" or similar
>
> and thus easily choose a preset text for the desired language. I attached
> a draft of this, which I couldn’t get to work, unfortunately, since
> \displayScheme can’t handle \header blocks. I think it gives an idea,
> nevertheless.
>
> What do you think?
>
> Yours, Simon
>
>
How about:
\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)))
englishTaglineText = #(format #f
"Music typeset using LilyPond ~a~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"
(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
}
{ c''1 }
HTH,
Harm
- Enhancement: automatically translate tagline, Simon Albrecht, 2015/03/15
- Re: Enhancement: automatically translate tagline,
Thomas Morley <=
- Re: Enhancement: automatically translate tagline, Simon Albrecht, 2015/03/15
- Re: Enhancement: automatically translate tagline, David Kastrup, 2015/03/16
- Re: Enhancement: automatically translate tagline, Simon Albrecht, 2015/03/16
- Re: Enhancement: automatically translate tagline, Noeck, 2015/03/16
- Re: Enhancement: automatically translate tagline, Simon Albrecht, 2015/03/16
- Re: Enhancement: automatically translate tagline, Noeck, 2015/03/16
- Re: Enhancement: automatically translate tagline, Simon Albrecht, 2015/03/25
Re: Enhancement: automatically translate tagline, Simon Albrecht, 2015/03/16