Event to detect when language changes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Haytam95
Posts: 23
Joined: Sun Mar 15, 2020 5:56 pm

Event to detect when language changes

Post by Haytam95 »

Hi!

I'm working on a Menu for a game, and I'm using TextTables and creating some scripts that converts text in (For example) TextMeshPro to the table field value, if match any.

That works okay, the trouble is, that I'd like to make this little scripts subscribe to some kind of Event, to detect when the user changes the language. That way, I would re-retrieve the values of the field with the new language.

Can I subscribe to an event that is fired when the language is changed? Is there such event? (And also, if i'm over complicating creating this scripts let me know!)

User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Event to detect when language changes

Post by Tony Li »

Hi,

If you make your script a subclass of the Dialogue System's LocalizeUI class, its UpdateText() method will be called whenever the language changes.

In the case of your script, you can just use LocalizeUI directly without having to write any scripts. It localizes TextMeshProUGUI and UI.Text components.
User avatar
Haytam95
Posts: 23
Joined: Sun Mar 15, 2020 5:56 pm

Re: Event to detect when language changes

Post by Haytam95 »

Ohh, alright so just by using LocalizeUI it will work (I just tested, worked at once!)

In the future, if I have another UI component that isn't a text or TextMeshPro (Which would be rare, now thinking about it) I should extend from LocalizeUI and then override UpdateText method, right?

Thanks Tony
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Event to detect when language changes

Post by Tony Li »

Hi,

Yes. That's all you need to do.
Post Reply