Translation on bubble speech from an array of strings not translated

Game development with Board Game Arena Studio
Post Reply
User avatar
Emanuele Ornella
Posts: 23
Joined: 09 January 2016, 19:07

Translation on bubble speech from an array of strings not translated

Post 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
Attachments
translation2.jpg
translation2.jpg (66.87 KiB) Viewed 967 times
translation1.jpg
translation1.jpg (150.76 KiB) Viewed 967 times
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

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

Post 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).
User avatar
Emanuele Ornella
Posts: 23
Joined: 09 January 2016, 19:07

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

Post by Emanuele Ornella »

Indeed I declared this in the constructor.
Moving this now in the setup and will check.
Thanks for the quick reply :-)
User avatar
Emanuele Ornella
Posts: 23
Joined: 09 January 2016, 19:07

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

Post by Emanuele Ornella »

It works!
Moving the declaration in the setup instead of the constructor fixed the translation problem!

Thanks again.
Ema
Post Reply

Return to “Developers”