cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX text translations typed text ID

XD
Associate III

Im trying to use the TouchGFX designer "text & translations" as a database of sorts.

I've tried to use the function getText(text id) from the Reference but i'm not able to locate the text ID. The code below is from the TouchGFX framework.

const touchgfx::Unicode::UnicodeChar* touchgfx::Texts::getText(TypedTextId id) const
{
    return &currentLanguagePtr[currentLanguageIndices[id]];
}

Searching through the project files for the TouchGFX Designer text ID returns the texts.xml file with IDs but that is more of an internal framework thing.

I simply want to do the following.

setLanguage(GB);
Text_GB = getText(Save);

setLanguage(DE);
Text_DE = getText(Save);

//Text_GB would be Save
//Text_DE would be Speichern

Below is an image from the designer with the IDs.

AlX1TDf

 

How would i go about doing this within the TouchGFX framework?
Any help is appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions

Oh I thought you already have the rest of the code, and you needed that specific function. 
If you want to get the text of the specified TextID, I suggest you to use this method instead:

const Unicode::UnicodeChar * textOfID = touchgfx::TypedText(T_SAVE).getText();

 

Let me know if you have more questions

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

3 REPLIES 3

Hello @XD 

Have you added "#include <texts/TextKeysAndLanguages.hpp>" to your project? You need this header to access the text IDs. But, keep that in mind that ids start with a capital T as prefix to the IDs you set. So, for instance, Save would be T_SAVE and you can see it in the included header. 
And it is also worth mentioning that you need to use the touchgfx::Text namespace to access getText() and setLanguage() (But, I assume you already know this).

I hope this helps you, good luck!

Mohammad MORADI
ST Software Developer | TouchGFX

Hi @Mohammad MORADI ESFAHANIASL 

Thanks for the info!
I just tried your suggestion but i'm unsure how to proceed.

getText(); is a part of the Texts class but what object should i use to access the getText function?

Unicode::UnicodeChar* Text =  touchgfx::Texts::OBJECT.getText(T_SAVE);

I shouldn't have to create a local "copy object" to access the text since it is already instantiated somewhere in the framework?
Maybe i have the wrong understanding?

Oh I thought you already have the rest of the code, and you needed that specific function. 
If you want to get the text of the specified TextID, I suggest you to use this method instead:

const Unicode::UnicodeChar * textOfID = touchgfx::TypedText(T_SAVE).getText();

 

Let me know if you have more questions

Mohammad MORADI
ST Software Developer | TouchGFX