Page 1 of 1

Localize array string

Posted: Thu Apr 25, 2024 12:30 pm
by Hisashi Joe
Hello,
I'm using Playmaker with Dialogue System.
I made an array that contains 20 string fields that will be called into an UI text element at certain point in my game.
I then want to localize these strings into another language so I added a Localize UI component to the UI text gameobject. Then I added all 20 strings to a localization text table. However, when each string is called, they only appear as English and not the current language.

I wonder if the text table does not work with array string?

Re: Localize array string

Posted: Thu Apr 25, 2024 3:36 pm
by Tony Li
Hi,

Are you using a Text Table asset? (Make sure you're not using the older, obsolete Localized Text Table asset type.) If so, you can add a Localize UI component to a Text, TextMeshPro, Dropdown, or TMP_Dropdown GameObject and set the Field value. If you leave the Field value blank, the Localize UI component will use the starting text value as the field name.

Or are you using the Playmaker integration's "Get Localized Text" action? This action will retrieve a localized field from a Text Table, which you can then show in your UI.

Re: Localize array string

Posted: Thu Apr 25, 2024 10:34 pm
by Hisashi Joe
Hello,
Yes, I'm using the new Text Table asset. My gameobject is setup like this with a string array variable:
Screenshot_7.png
Screenshot_7.png (25.53 KiB) Viewed 307 times
And I added the strings to a Text Table asset:
Screenshot_8.png
Screenshot_8.png (37.58 KiB) Viewed 307 times
Then in that gameobject's FSM, I have it setup like this:
Screenshot_9.png
Screenshot_9.png (35.01 KiB) Viewed 307 times
Screenshot_10.png
Screenshot_10.png (35.92 KiB) Viewed 307 times
Which will randomly choose a string from the array and then populate the UI text with that chosen string every 1 second.
The UI text also has this:
Screenshot_11.png
Screenshot_11.png (38.85 KiB) Viewed 307 times
And when the language is set to ja, the string from the array does not get translated.
There are other UI text in the same scene that get translated correctly but they use predetermined string.
I hope this make my question clearer.

Re: Localize array string

Posted: Fri Apr 26, 2024 8:41 am
by Tony Li
Hi,

In this case, do not use LocalizeUI. Instead, since you're pulling random strings from a table in Playmaker, use the "Get Localized Text" action in Playmaker to get the translation, and then set the Text component to that translation.

Re: Localize array string

Posted: Fri Apr 26, 2024 10:02 am
by Hisashi Joe
Thanks, Tony! It works!
I saw the Get localized field action before but I had a different understanding of it. I should have tried it first. Thanks for sticking with me!

Re: Localize array string

Posted: Fri Apr 26, 2024 12:26 pm
by Tony Li
Happy to help!