Localize array string

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Hisashi Joe
Posts: 6
Joined: Thu Apr 25, 2024 12:24 pm

Localize array string

Post 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?
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize array string

Post 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.
Hisashi Joe
Posts: 6
Joined: Thu Apr 25, 2024 12:24 pm

Re: Localize array string

Post 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 309 times
And I added the strings to a Text Table asset:
Screenshot_8.png
Screenshot_8.png (37.58 KiB) Viewed 309 times
Then in that gameobject's FSM, I have it setup like this:
Screenshot_9.png
Screenshot_9.png (35.01 KiB) Viewed 309 times
Screenshot_10.png
Screenshot_10.png (35.92 KiB) Viewed 309 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 309 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.
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize array string

Post 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.
Hisashi Joe
Posts: 6
Joined: Thu Apr 25, 2024 12:24 pm

Re: Localize array string

Post 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!
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize array string

Post by Tony Li »

Happy to help!
Post Reply