]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/musicexp.py
Improve Python scripts localization
[lilypond.git] / python / musicexp.py
index 07af416ab779ef2d024423e98b13baa821fde1d6..b266830d0726bd32e43b884e5ae1e6e2f795836a 100644 (file)
@@ -2,6 +2,9 @@ import inspect
 import sys
 import string
 import re
+import lilylib
+
+_ = lilylib._
 
 from rational import Rational
 
@@ -9,6 +12,10 @@ from rational import Rational
 previous_pitch = None
 relative_pitches = False
 
+def warning (str):
+    ly.stderr_write ((_ ("warning: %s") % str) + "\n")
+
+
 def escape_instrument_string (input_string):
     retstring = string.replace (input_string, "\"", "\\\"")
     if re.match ('.*[\r\n]+.*', retstring):
@@ -567,7 +574,8 @@ class RepeatedMusic:
             self.music = SequentialMusic ()
             self.music.elements = music
         else:
-            sys.stderr.write (_ ("WARNING: Unable to set the music %s for the repeat %s" % (music, self)))
+            warning (_ ("unable to set the music %(music)s for the repeat %(repeat)s" % \
+                            {'music':music, 'repeat':self}))
     def add_ending (self, music):
         self.endings.append (music)
     def print_ly (self, printer):
@@ -575,7 +583,7 @@ class RepeatedMusic:
         if self.music:
             self.music.print_ly (printer)
         else:
-            sys.stderr.write (_ ("WARNING: Encountered repeat without body\n"))
+            warning (_ ("encountered repeat without body"))
             printer.dump ('{}')
         if self.endings:
             printer.dump ('\\alternative {')