Forums » General Questions » Display text depending on language

1
I'm trying to translate a chart's lua into Spanish by making the code load a text if Spanish language setting is detected, and display another text if it's using any other language but sadly, I can't make it work. Here's my code:

  Def.BitmapText{

Name= "actor_Cc",
Font= "_eurostile normal",
InitCommand= cmd(horizalign,left;x,SCREEN_LEFT+10;y,SCREEN_CENTER_Y-170),
OnCommand= cmd(cropright,1;sleep,6.5;linear,8.5;cropright,0;sleep,0.2;linear,0.5;diffusealpha,0;playcommand,Set),
SetCommand= function(self)
local language = THEME:GetCurLanguage()
if language == es then
self:settext("You are using Spanish.")
else then
self:settext("You are not using Spanish.")
end
end;
},


What's wrong with it? I've also tried to use quotation marks in "es" but it didn't work.

EDIT: A solution has been found. Saving for future reference.
you need quotes around "es", and you shouldn't have "then" after "else". otherwise looks right, if it doesn't work see what GetCurLanguage is actually telling you using trace() and checking the log file
Try writing your playcommand as playcommand,"Set"

Last edited: 29 November 2016 2:20pm

~Santikun
Reply
you need quotes around "es", and you shouldn't have "then" after "else". otherwise looks right, if it doesn't work see what GetCurLanguage is actually telling you using trace() and checking the log file
Reply
you need quotes around "es", and you shouldn't have "then" after "else". otherwise looks right, if it doesn't work see what GetCurLanguage is actually telling you using trace() and checking the log file

Adding quotes on "es" and removing "then" after "else" displays the textbox (unlike other variants of the code), but it does not display any text. What could be causing this?
~Santikun
Reply
Adding quotes on "es" and removing "then" after "else" displays the textbox (unlike other variants of the code), but it does not display any text. What could be causing this?

Try writing your playcommand as playcommand,"Set"
Reply
Try writing your playcommand as playcommand,"Set"

Amazing, it works now. Thank you so much! This will be really useful. :)
~Santikun
Reply