FText::Format does not work correctly with FText::AsNumber and NSLOCTEXT

Sorry, not a bug :slight_smile:

The first parameter needs to be a format string specifier. I’ve commented more on your original question about this: How can I Concatenate FText Together? - Programming & Scripting - Epic Developer Community Forums

The first string needs to be a format specifier, you can also include text in this if you need to (just like with printf formatting), so you probably want something like this (the syntax is more like the Python str.format style to support re-ordering for localisation):

FText::Format(NSLOCTEXT("Solus","DayFmt","{0} {1}"), NSLOCTEXT("Solus","Solus","Day"), FText::AsNumber(DayCount)); // takes both as arguments
FText::Format(NSLOCTEXT("Solus","Solus","Day {0}"), FText::AsNumber(DayCount)); // takes just the day number and formats it into the Day string

You can also do the formatting as key->value pairs of formatting arguments:

FFormatNamedArguments Args;
Args.Add("DayCount", DayCount);
FText::Format(NSLOCTEXT("Solus","Day","Day {DayCount}"), Args);

Or alternatively, as an array of arguments:

FFormatOrderedArguments Args;
Args.Add(DayCount);
FText::Format(NSLOCTEXT("Solus","Day","Day {0}"), Args);
2 Likes