Allow music title to be translatable, fix #4281
This commit is contained in:
parent
28b9d3aea8
commit
d03a821e53
@ -5,7 +5,7 @@ import codecs
|
||||
f = open('./data/po/gui_strings.h', 'w')
|
||||
f.write( codecs.BOM_UTF8 )
|
||||
|
||||
def traverse(file, node, isChallenge, isGP, isKart, isTrack, isAchievements, level=0):
|
||||
def traverse(file, node, isChallenge, isGP, isKart, isTrack, isAchievements, isMusic, level=0):
|
||||
|
||||
for e in node.childNodes:
|
||||
if e.localName == None:
|
||||
@ -17,6 +17,11 @@ def traverse(file, node, isChallenge, isGP, isKart, isTrack, isAchievements, lev
|
||||
if e.hasAttribute("I18N"):
|
||||
comment = e.getAttribute("I18N")
|
||||
|
||||
if isMusic and e.hasAttribute("title") and len(e.getAttribute("title")) > 0:
|
||||
line = ""
|
||||
line += "//I18N: Music title from " + file + "\n_(\"" + e.getAttribute("title") + "\");\n\n"
|
||||
f.write( line.encode( "utf-8" ) )
|
||||
|
||||
if e.localName == "subtitle" and e.hasAttribute("text") and len(e.getAttribute("text")) > 0:
|
||||
#print "Label=", e.getAttribute("name"), " Comment=", comment
|
||||
line = ""
|
||||
@ -61,7 +66,7 @@ def traverse(file, node, isChallenge, isGP, isKart, isTrack, isAchievements, lev
|
||||
|
||||
# don't recurse in children nodes for karts, they can contain sounds, etc. that should not be translated
|
||||
if not isKart:
|
||||
traverse(file, e, isChallenge, isGP, isKart, isTrack, isAchievements, level+1)
|
||||
traverse(file, e, isChallenge, isGP, isKart, isTrack, isAchievements, isMusic, level+1)
|
||||
|
||||
filenames = sys.argv[1:]
|
||||
for file in filenames:
|
||||
@ -72,6 +77,7 @@ for file in filenames:
|
||||
isKart = False
|
||||
isTrack = False
|
||||
isAchievements = False
|
||||
isMusic = False
|
||||
|
||||
if file.endswith(".challenge"):
|
||||
isChallenge = True
|
||||
@ -83,6 +89,8 @@ for file in filenames:
|
||||
isTrack = True
|
||||
if file.endswith("achievements.xml"):
|
||||
isAchievements = True
|
||||
if file.endswith(".music"):
|
||||
isMusic = True
|
||||
|
||||
try:
|
||||
doc = xml.dom.minidom.parse(file)
|
||||
@ -91,5 +99,5 @@ for file in filenames:
|
||||
print("/!\\ Expat doesn't like ", file, "! Error=", type(ex), " (", ex.args, ")")
|
||||
print("============================================")
|
||||
|
||||
traverse(file, doc, isChallenge, isGP, isKart, isTrack, isAchievements)
|
||||
traverse(file, doc, isChallenge, isGP, isKart, isTrack, isAchievements, isMusic)
|
||||
|
||||
|
@ -11,8 +11,10 @@ CPP_FILE_LIST="`find ./src \
|
||||
XML_FILE_LIST="`find ./data \
|
||||
../stk-assets/tracks \
|
||||
../stk-assets/karts \
|
||||
../stk-assets/music \
|
||||
../supertuxkart-assets/tracks \
|
||||
../supertuxkart-assets/karts \
|
||||
../supertuxkart-assets/music \
|
||||
-name 'achievements.xml' -or \
|
||||
-name 'tips.xml' -or \
|
||||
-name 'kart.xml' -or \
|
||||
@ -20,6 +22,7 @@ XML_FILE_LIST="`find ./data \
|
||||
-name 'scene.xml' -or \
|
||||
-name '*.challenge' -or \
|
||||
-name '*.grandprix' -or \
|
||||
-name '*.music' -or \
|
||||
-name '*.stkgui' | sort -n \
|
||||
`"
|
||||
ANGELSCRIPT_FILE_LIST="`find ./data \
|
||||
|
@ -626,8 +626,9 @@ void RaceGUIBase::drawGlobalMusicDescription()
|
||||
const MusicInformation* mi = music_manager->getCurrentMusic();
|
||||
if (!mi) return;
|
||||
|
||||
core::stringw title = translations->w_gettext(mi->getTitle().c_str());
|
||||
// I18N: string used to show the song title (e.g. "Sunny Song")
|
||||
core::stringw thetext = _("\"%s\"", mi->getTitle());
|
||||
core::stringw thetext = _("\"%s\"", title);
|
||||
|
||||
core::dimension2d< u32 > textSize = font->getDimension(thetext.c_str());
|
||||
int textWidth = textSize.Width;
|
||||
|
Loading…
Reference in New Issue
Block a user