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 = open('./data/po/gui_strings.h', 'w')
|
||||||
f.write( codecs.BOM_UTF8 )
|
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:
|
for e in node.childNodes:
|
||||||
if e.localName == None:
|
if e.localName == None:
|
||||||
@ -16,7 +16,12 @@ def traverse(file, node, isChallenge, isGP, isKart, isTrack, isAchievements, lev
|
|||||||
comment = None
|
comment = None
|
||||||
if e.hasAttribute("I18N"):
|
if e.hasAttribute("I18N"):
|
||||||
comment = e.getAttribute("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:
|
if e.localName == "subtitle" and e.hasAttribute("text") and len(e.getAttribute("text")) > 0:
|
||||||
#print "Label=", e.getAttribute("name"), " Comment=", comment
|
#print "Label=", e.getAttribute("name"), " Comment=", comment
|
||||||
line = ""
|
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
|
# don't recurse in children nodes for karts, they can contain sounds, etc. that should not be translated
|
||||||
if not isKart:
|
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:]
|
filenames = sys.argv[1:]
|
||||||
for file in filenames:
|
for file in filenames:
|
||||||
@ -72,7 +77,8 @@ for file in filenames:
|
|||||||
isKart = False
|
isKart = False
|
||||||
isTrack = False
|
isTrack = False
|
||||||
isAchievements = False
|
isAchievements = False
|
||||||
|
isMusic = False
|
||||||
|
|
||||||
if file.endswith(".challenge"):
|
if file.endswith(".challenge"):
|
||||||
isChallenge = True
|
isChallenge = True
|
||||||
if file.endswith(".grandprix"):
|
if file.endswith(".grandprix"):
|
||||||
@ -83,7 +89,9 @@ for file in filenames:
|
|||||||
isTrack = True
|
isTrack = True
|
||||||
if file.endswith("achievements.xml"):
|
if file.endswith("achievements.xml"):
|
||||||
isAchievements = True
|
isAchievements = True
|
||||||
|
if file.endswith(".music"):
|
||||||
|
isMusic = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
doc = xml.dom.minidom.parse(file)
|
doc = xml.dom.minidom.parse(file)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@ -91,5 +99,5 @@ for file in filenames:
|
|||||||
print("/!\\ Expat doesn't like ", file, "! Error=", type(ex), " (", ex.args, ")")
|
print("/!\\ Expat doesn't like ", file, "! Error=", type(ex), " (", ex.args, ")")
|
||||||
print("============================================")
|
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 \
|
XML_FILE_LIST="`find ./data \
|
||||||
../stk-assets/tracks \
|
../stk-assets/tracks \
|
||||||
../stk-assets/karts \
|
../stk-assets/karts \
|
||||||
|
../stk-assets/music \
|
||||||
../supertuxkart-assets/tracks \
|
../supertuxkart-assets/tracks \
|
||||||
../supertuxkart-assets/karts \
|
../supertuxkart-assets/karts \
|
||||||
|
../supertuxkart-assets/music \
|
||||||
-name 'achievements.xml' -or \
|
-name 'achievements.xml' -or \
|
||||||
-name 'tips.xml' -or \
|
-name 'tips.xml' -or \
|
||||||
-name 'kart.xml' -or \
|
-name 'kart.xml' -or \
|
||||||
@ -20,6 +22,7 @@ XML_FILE_LIST="`find ./data \
|
|||||||
-name 'scene.xml' -or \
|
-name 'scene.xml' -or \
|
||||||
-name '*.challenge' -or \
|
-name '*.challenge' -or \
|
||||||
-name '*.grandprix' -or \
|
-name '*.grandprix' -or \
|
||||||
|
-name '*.music' -or \
|
||||||
-name '*.stkgui' | sort -n \
|
-name '*.stkgui' | sort -n \
|
||||||
`"
|
`"
|
||||||
ANGELSCRIPT_FILE_LIST="`find ./data \
|
ANGELSCRIPT_FILE_LIST="`find ./data \
|
||||||
|
@ -626,8 +626,9 @@ void RaceGUIBase::drawGlobalMusicDescription()
|
|||||||
const MusicInformation* mi = music_manager->getCurrentMusic();
|
const MusicInformation* mi = music_manager->getCurrentMusic();
|
||||||
if (!mi) return;
|
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")
|
// 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());
|
core::dimension2d< u32 > textSize = font->getDimension(thetext.c_str());
|
||||||
int textWidth = textSize.Width;
|
int textWidth = textSize.Width;
|
||||||
|
Loading…
Reference in New Issue
Block a user