Download

[Solved] Using FText::Format with TexBlock Text from StringTable

Hi!
How could I use FText::Format to change TextBlock Text value? Its value is from StringTable.

What’s happening:
1 - I’m using StringTable because of localization, one value stored is: “{0} Health”.
2 - TextBlock Text is using “{0} Health” in Blueprint “Referenced Text”.
3 - How could I use FText::Format to change the placeholder?

Thank you!

From my page on localizing UIs in Unreal, you can use FFormatNamedArgs and pass that into FText::Format:


int32 Value = 150;

FText FormatInput = FText::FromStringTable("MyTable", "HealthFormat");

FFormatNamedArguments Args;
Args.Add("HealthValue", Value);
FText FormattedText = FText::Format( FormatInput, Args );

Thank you @benhumphreys !
I’ve been reading your articles for some time, it was reading your site that I learned the UserWidget/Localization in C++ and best pratices!
I have an open tab to read your new article Choosing a minimum resolution.
Once again, thank you very much!