FText
#include "Internationalization/Text.h" Description
A localizable string that carries culture-aware display data. Use FText for any text shown to end-users so it can be properly localized.
Caveats & Gotchas
- • Never build user-facing strings from FString and display them directly. Always route through FText (NSLOCTEXT, LOCTEXT, or FText::Format) so the localization pipeline can process them.
- • FText is not directly usable as a TMap key because it lacks a stable hash. Convert to FString first if you need hashing, accepting that you lose the localization context.
- • FText::FromString() creates a culture-invariant text flagged as InitializedFromString. It will not be picked up by the localization dashboard — use it only for debug output or non-localizable strings.
- • FText instances are internally ref-counted via TSharedRef<ITextData>. Copying is cheap but not free; prefer const FText& in APIs that don't need ownership.
Examples
Defining and displaying localized text C++
#define LOCTEXT_NAMESPACE "MyGameUI"
FText PickupMsg = NSLOCTEXT("MyGameUI", "ItemPickedUp", "Item picked up!");
MyWidget->SetText(PickupMsg);
#undef LOCTEXT_NAMESPACE FText::Format for parameterized strings C++
FText Msg = FText::Format(
NSLOCTEXT("MyGame", "DamageDealt", "You dealt {Damage} damage!"),
FText::AsNumber(42)
); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?