Can I use LocalizeUI's 'Field Name' for localize & update?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wlchfl5359
Posts: 29
Joined: Sat Jan 02, 2021 4:27 pm

Can I use LocalizeUI's 'Field Name' for localize & update?

Post by wlchfl5359 »

Hi,

I was changing text like

titletext.text = DialogueManager.GetLocalizedText(_data.taskName);

But I figured out it doesn't change language when I use DialogueManager.SetLanguage("english");
So I had to use this method "titletext.text = DialogueManager.GetLocalizedText(_data.taskName);" again to refresh it.

So I used LocalizeUI like this

localizeUnitName.fieldName = _data.taskName;
localizeUnitName.UpdateText();

Now it works well when I change language.

But I wonder whether this way changing Field Name is good way to change language.

Thank you.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I use LocalizeUI's 'Field Name' for localize & update?

Post by Tony Li »

Hi,

Are you using the current version of the Dialogue System? If so, then DialogueManager.SetLanguage("english") should tell all LocalizeUI components to update their texts according to the LocalizeUI's current field name.

When you set up the LocalizeUI component, you can specify a field name. If you leave the field name blank, LocalizeUI will use the text component's starting text value as the field name.

If you want to change the field name, you can use the code you showed above.
wlchfl5359
Posts: 29
Joined: Sat Jan 02, 2021 4:27 pm

Re: Can I use LocalizeUI's 'Field Name' for localize & update?

Post by wlchfl5359 »

Oh, I'm using 2.2.39 now and I will update now.

I set some text like this titletext.text = DialogueManager.GetLocalizedText(_data.taskName) and use it for character name or something else.

Field name is default text.

Then I change languages, it doesn't change because text is now localizedText.

field name is still same.

Other texts that I set in the inspector changes well.

So I should set text again or set Field Name instead TMP text at first.

Then it changes well.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Can I use LocalizeUI's 'Field Name' for localize & update?

Post by Tony Li »

Hi,

Yes, that's correct. In that case, the best approach is to set the field name and then call UpdateText().
Post Reply