Change Button Text with Array

Hey!

I a set of buttons, created after a main parent in which the buttons text is set by a variable that applies the text in the cosntruction script.

Like this:

The things is, I need these text to be translatable by clicking in a language button selector (2 languages, 2 buttons), but I’m struggling to make it work… I don’t know how or where to get it to work with all the buttons.

Have you guys set up something like this before? And if so, what’s the best and most performative way of doing this, without having to create secondary buttons for the other language, and having it change with individual buttons everytime…

Note:This is a tempalte project for myself, so it needs to be ready to dynamically be changed into anything… So it really matters that even the translating process is made in the same place, without having to open/edit one button at a time.

If someone could shine a light on this, I would be really grateful!

Thank you!

I have this working and here’s how I have it:

  1. Whenever you change the language, GameInstance is notified about it, and it calls an event OnLanguageChanged.
  2. Every widget, when created, binds to the OnLanguageChanged event of the GameInstance.
  3. When this event is called, the widget changes the text.

Or alternatively: a button is a separate widget that handles its text. But it’s the same: it waits for the event, and reacts to it.

2 Likes