Page 1 of 1
translation not detected in object
Posted: 17 October 2020, 20:21
by MikeIsHere
I have the following object in my game
Code: Select all
this.translatedText = {
"cribYourTurn":_('You must choose 2 cards to give to Your crib'),
"giveCards":_('Give selected cards'),
"go": _('Go'),
"errorGiveCards":_('You must select exactly 2 cards')
};
But on the translation page none of these strings show up. What did I do wrong?
Re: translation not detected in object
Posted: 17 October 2020, 21:36
by fafa-fr
Hi,
Is this located in your constructor?
This post may help you:
Een wrote: ↑17 June 2020, 17:52
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).
But I wonder why strings as an object variable are not translated, could we have an explanation?
Re: translation not detected in object
Posted: 18 October 2020, 11:16
by Een
fafa-fr wrote: ↑17 October 2020, 21:36
This post may help you:
Een wrote: ↑17 June 2020, 17:52
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).
Not sure if it's the same, if I remember correctly in that case strings were available in the translation interface, just not applied.
fafa-fr wrote: ↑17 October 2020, 21:36
But I wonder why strings as an object variable are not translated, could we have an explanation?
Applying the translation with _() is a dynamic function, so to occur it needs the object to be fully initialized with the i18n dependency.
Re: translation not detected in object
Posted: 18 October 2020, 11:46
by MikeIsHere
Thank you for your explanation and it work Yes the strings are being applied but they weren't showing up in the translation screen which makes sense when you take into account like you said the il8n being immortalized