Page 1 of 1

Translation on bubble speech from an array of strings not translated

Posted: 17 June 2020, 17:17
by Emanuele Ornella
I have a problem on the translation of some strings.
The funny thing is that these are appearing in the translation tool and are actually translated.
However only the English version is appearing in the game, no matter which locale is selected.

I have created an array with different quotes from Alice in Wonderland for Tea Time:

Code: Select all

this.quotes = [
							// Alice
							[_("And what is the use of a book without pictures or conversations?"),
							 _("Why, sometimes I've believed as many as six impossible things before breakfast."),
							 _("Who in the world am I? Ah, that's the great puzzle!"),
							 _("Curiouser and curiouser!"),
							 _("How long is forever?"),
							 _("I'm afraid I can't explain myself, sir. Because I am not myself, you see?"),
							 _("I knew who I was this morning, but I've changed a few times since then.")
							],
							// Cat
							[_("We’re all mad here. I’m mad. You’re mad."),
							 
							 _("That depends a good deal on where you want to get to."),
							 _("Where are you going?")
							],
							// Queen
							[_("Off with her head!"),
							 _("My dear, here we must run as fast as we can, just to stay in place."),
							 _("And if you wish to go anywhere you must run twice as fast as that."),
							 _("It is better to be feared than loved."),
							 _("It's a poor sort of memory that only works backwards"),
							 _("I’m just one hundred and one, five months and a day."),
							 _("If everybody minded their own business."),
							 _("Take care of the sense, and the sounds will take care of themselves.")
							],
							// Hatter
							[_("Then you shouldn’t talk."),
							 _("Why is a raven like a writing-desk?"),
							 _("it's always tea time."),
							 _("You mean you ca’n’t take less, it’s very easy to take more than nothing.")
							],
							//Caterpillar
							[_("Who are you?"),
							 _("What do you mean by that?"),
							 _("Explain yourself.")
							],
							// Rabbit
							[_("Sometimes, just one second."),
							 _("The Duchess! The Duchess! Oh my dear paws!"),
							 _("I'm late, I'm late! For a very important date!"),
							 _("No time to say ‘hello, goodbye,’ I’m late, I’m late, I’m late!"),
							 _("This watch is exactly two days late!"),
							 _("The hurrier I go, the behinder I get!")
							],
							//Twins
							[_("Contrariwise!"),
							 _("If it was so, it might be; and if it were so, it would be."),
							 _("But as it isn't, it ain't. That's logic.")
							]
							
			
						   ];
In all of these I have used _( ) function for the translation.

At the click I am randomizing the quote for the specific card number:

Code: Select all

var thequote = "";
var randomquote = Math.floor(Math.random() * this.quotes[cardnumber].length);
thequote = this.quotes[cardnumber][randomquote];
And then use thequote variable in the showBubble function

Code: Select all

this.showBubble( dojo.byId('funnyquotesdiv'), thequote, 10, thequote.length*100,"bubble_custom" );
In the translation tool these texts are present and translated. However these are not appearing in the game.
Please see the two screenshots attached.

Any idea what am I doing wrong?
Thanks,
Ema

Re: Translation on bubble speech from an array of strings not translated

Posted: 17 June 2020, 17:52
by Een
I have already seen this trouble, and the reason was that the string declaration was as an object variable or in the constructor and didn't have the proper context for translations to occur. If the strings are declared in the setup function then it works (you can check the Red7 project on the studio for an example).

Re: Translation on bubble speech from an array of strings not translated

Posted: 17 June 2020, 17:59
by Emanuele Ornella
Indeed I declared this in the constructor.
Moving this now in the setup and will check.
Thanks for the quick reply :-)

Re: Translation on bubble speech from an array of strings not translated

Posted: 17 June 2020, 18:43
by Emanuele Ornella
It works!
Moving the declaration in the setup instead of the constructor fixed the translation problem!

Thanks again.
Ema