Skip to main content
HTD
Senior II
September 4, 2022
Question

TouchGFX - can't switch language.

  • September 4, 2022
  • 4 replies
  • 1216 views

I defined a text in 3 languages in Texts in Designer.

When I set the language in the designer, my label is translated correctly.

Then I made 3 buttons and assigned "ChangeLanguage" action to each.

When I run the application and click the buttons - nothing happens.

Here's the function the TouchGFX generated:

void Screen1ViewBase::buttonCallbackHandler(const touchgfx::AbstractButton& src)
{
 if (&src == &langGB)
 {
 //Interaction1
 //When langGB clicked set language GB
 //Change language to GB
 Texts::setLanguage(GB);
 invalidate();
 
 //Interaction4
 //When Interaction1 completed call virtual function
 //Call redraw
 redraw();
 }
 else if (&src == &langPL)
 {
 //Interaction2
 //When langPL clicked set language PL
 //Change language to PL
 Texts::setLanguage(PL);
 invalidate();
 
 //Interaction5
 //When Interaction2 completed call virtual function
 //Call redraw
 redraw();
 }
 else if (&src == &langZA)
 {
 //Interaction3
 //When langZA clicked set language ZA
 //Change language to ZA
 Texts::setLanguage(ZA);
 invalidate();
 
 //Interaction6
 //When Interaction3 completed call virtual function
 //Call redraw
 redraw();
 }
}

The functions are called, but well, nothing happens. The label is not translated.

This topic has been closed for replies.

4 replies

HTD
HTDAuthor
Senior II
September 4, 2022

Ooopsie! Why is this always happening when I ask the question? Somehow my texts changed to the same text in all languages. So it worked, but all translations were the same. I changed the translations again and now it works.

Osman SOYKURT
ST Technical Moderator
September 5, 2022

Hello HTD,

So everything is working fine?

We're doing a new tutorial about how to use texts and add new languages. We'll make it available on our support website soon :)

/Osman

ST Software Developer | TouchGFX
HTD
HTDAuthor
Senior II
September 6, 2022

Yes, I'm just making multilingual UI and I'm amazed how quick and easy it is.

Osman SOYKURT
ST Technical Moderator
September 6, 2022

Awesome, great to hear that!

/Osman

ST Software Developer | TouchGFX