translation not detected in object

Game development with Board Game Arena Studio
Post Reply
User avatar
MikeIsHere
Posts: 84
Joined: 30 April 2020, 22:52

translation not detected in object

Post by MikeIsHere » 17 October 2020, 20:21

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?

User avatar
fafa-fr
Posts: 284
Joined: 22 December 2013, 21:58

Re: translation not detected in object

Post by fafa-fr » 17 October 2020, 21:36

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?

User avatar
Een
Posts: 2836
Joined: 16 June 2010, 19:52

Re: translation not detected in object

Post by Een » 18 October 2020, 11:16

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.

User avatar
MikeIsHere
Posts: 84
Joined: 30 April 2020, 22:52

Re: translation not detected in object

Post by MikeIsHere » 18 October 2020, 11:46

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

Post Reply

Return to “Developers”