UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TextNamespaceUtil Namespace Reference

Enumerations

enum class  ETextCopyMethod : uint8 { NewKey , PreserveKey , Verbatim }
 
enum class  ETextEditAction : uint8 { Namespace , Key , SourceString }
 

Functions

CORE_API FString BuildFullNamespace (const FString &InTextNamespace, const FString &InPackageNamespace, const bool bAlwaysApplyPackageNamespace=false)
 
CORE_API FString ExtractPackageNamespace (const FString &InTextNamespace)
 
CORE_API FString StripPackageNamespace (const FString &InTextNamespace)
 
CORE_API void StripPackageNamespaceInline (FString &InOutTextNamespace)
 
CORE_API FText CopyTextToPackage (const FText &InText, const FString &InPackageNamespace, const ETextCopyMethod InCopyMethod=ETextCopyMethod::NewKey, const bool bAlwaysApplyPackageNamespace=false)
 
COREUOBJECT_API FText CopyTextToPackage (const FText &InText, UPackage *InPackage, const ETextCopyMethod InCopyMethod=ETextCopyMethod::NewKey, const bool bAlwaysApplyPackageNamespace=false)
 
COREUOBJECT_API FText CopyTextToPackage (const FText &InText, UObject *InObject, const ETextCopyMethod InCopyMethod=ETextCopyMethod::NewKey, const bool bAlwaysApplyPackageNamespace=false)
 
COREUOBJECT_API FString GenerateRandomTextKey ()
 
COREUOBJECT_API FString GenerateDeterministicTextKey (UObject *InTextOwner, const FTextProperty *InTextProperty, const bool bApplyPackageNamespace=true)
 
COREUOBJECT_API FString GenerateDeterministicTextKey (UObject *InTextOwner, const FName InTextPropertyName, const bool bApplyPackageNamespace=true)
 
COREUOBJECT_API void GetTextIdForEdit (UPackage *InPackage, const ETextEditAction InEditAction, const FString &InTextSource, const FString &InProposedNamespace, const FString &InProposedKey, FString &OutStableNamespace, FString &OutStableKey, TFunctionRef< FString()> InTextKeyGenerator=&GenerateRandomTextKey, const bool bApplyPackageNamespace=true)
 
COREUOBJECT_API bool EditTextProperty (UObject *InTextOwner, const FTextProperty *InTextProperty, const ETextEditAction InEditAction, const FString &InEditValue, TFunctionRef< FString()> InTextKeyGenerator=&GenerateRandomTextKey, const bool bApplyPackageNamespace=true)
 
COREUOBJECT_API bool EditTextProperty_Direct (UPackage *InPackage, void *InTextValue, const FTextProperty *InTextProperty, const ETextEditAction InEditAction, const FString &InEditValue, TFunctionRef< FString()> InTextKeyGenerator=&GenerateRandomTextKey, const bool bApplyPackageNamespace=true)
 

Variables

constexpr TCHAR PackageNamespaceStartMarker = TEXT('[')
 
constexpr TCHAR PackageNamespaceEndMarker = TEXT(']')
 

Enumeration Type Documentation

◆ ETextCopyMethod

Enumerator
NewKey 

Give the text a new key if the full namespace changes

PreserveKey 

Keep the existing key if the full namespace changes

Verbatim 

Copy the text verbatim, disregarding any full namespace changes

◆ ETextEditAction

Enumerator
Namespace 
Key 
SourceString 

Function Documentation

◆ BuildFullNamespace()

FString TextNamespaceUtil::BuildFullNamespace ( const FString &  InTextNamespace,
const FString &  InPackageNamespace,
const bool  bAlwaysApplyPackageNamespace = false 
)

Given a text and package namespace, build the full version that should be used by the localization system. This can also be used to "zero-out" the package namespace used by a text namespace (by passing an empty package namespace) while still leaving the package namespace markers in place.

Parameters
InTextNamespaceThe namespace currently used by the FText instance.
InPackageNamespaceThe namespace of the package owning the FText instance.
bAlwaysApplyPackageNamespaceIf true, this will always apply the package namespace to the text namespace. If false, this will only apply the package namespace if the text namespace already contains package namespace markers.
Returns
The full namespace that should be used by the localization system.

◆ CopyTextToPackage() [1/3]

FText TextNamespaceUtil::CopyTextToPackage ( const FText InText,
const FString &  InPackageNamespace,
const ETextCopyMethod  InCopyMethod = ETextCopyMethod::NewKey,
const bool  bAlwaysApplyPackageNamespace = false 
)

Make a copy of the given text that's valid to use with the given package namespace, optionally preserving its existing key.

Note
Returns the result verbatim if the given package namespace is empty, or if there is no change when applying the package namespace to the text.
Parameters
InTextThe current FText instance.
InPackageNamespaceThe namespace of the destination package of the FText instance.
InCopyMethodThe method that should be used to copy the FText instance.
bAlwaysApplyPackageNamespaceIf true, this will always apply the package namespace to the text namespace (always treated as ETextCopyMethod::Verbatim when USE_STABLE_LOCALIZATION_KEYS is false). If false, this will only apply the package namespace if the text namespace already contains package namespace markers.
Returns
A copy of the given text that's valid to use with the given package namespace.

◆ CopyTextToPackage() [2/3]

FText TextNamespaceUtil::CopyTextToPackage ( const FText InText,
UObject InObject,
const ETextCopyMethod  InCopyMethod = ETextCopyMethod::NewKey,
const bool  bAlwaysApplyPackageNamespace = false 
)

◆ CopyTextToPackage() [3/3]

FText TextNamespaceUtil::CopyTextToPackage ( const FText InText,
UPackage InPackage,
const ETextCopyMethod  InCopyMethod = ETextCopyMethod::NewKey,
const bool  bAlwaysApplyPackageNamespace = false 
)

Make a copy of the given text that's valid to use with the given package, optionally preserving its existing key.

Note
Returns the result verbatim if there is no change when applying the package namespace to the text.
Parameters
InTextThe current FText instance.
InPackage/InObjectThe package (or object to get the owner package from) to get the namespace for (will call EnsurePackageNamespace).
InCopyMethodThe method that should be used to copy the FText instance.
bAlwaysApplyPackageNamespaceIf true, this will always apply the package namespace to the text namespace (always treated as ETextCopyMethod::Verbatim when USE_STABLE_LOCALIZATION_KEYS is false). If false, this will only apply the package namespace if the text namespace already contains package namespace markers.
Returns
A copy of the given text that's valid to use with the given package.

◆ EditTextProperty()

bool TextNamespaceUtil::EditTextProperty ( UObject InTextOwner,
const FTextProperty InTextProperty,
const ETextEditAction  InEditAction,
const FString &  InEditValue,
TFunctionRef< FString()>  InTextKeyGenerator = &GenerateRandomTextKey,
const bool  bApplyPackageNamespace = true 
)

Edit an attribute of the given text property, akin to what happens when editing a text property in a details panel.

Parameters
InTextOwnerThe object that owns the given TextProperty to be edited.
InTextPropertyThe text property to edit. This must be a property that exists on TextOwner.
InEditActionHow has the given text been edited?
InEditValueThe new value of the attribute that was edited.
InTextKeyGeneratorGenerator for the new text key. Will generate a random key by default.
bApplyPackageNamespaceIf true, apply the package namespace to the generated text ID (when USE_STABLE_LOCALIZATION_KEYS is true).
Returns
True if edit was possible, or false if not.

◆ EditTextProperty_Direct()

bool TextNamespaceUtil::EditTextProperty_Direct ( UPackage InPackage,
void InTextValue,
const FTextProperty InTextProperty,
const ETextEditAction  InEditAction,
const FString &  InEditValue,
TFunctionRef< FString()>  InTextKeyGenerator = &GenerateRandomTextKey,
const bool  bApplyPackageNamespace = true 
)

Edit an attribute of the given text property, akin to what happens when editing a text property in a details panel.

Parameters
InPackageThe package that hosts the text value.
InTextValueThe raw value of the TextProperty to be edited.
InTextPropertyThe text property to edit.
InEditActionHow has the given text been edited?
InEditValueThe new value of the attribute that was edited.
InTextKeyGeneratorGenerator for the new text key. Will generate a random key by default.
bApplyPackageNamespaceIf true, apply the package namespace to the generated text ID (when USE_STABLE_LOCALIZATION_KEYS is true).
Returns
True if edit was possible, or false if not.

◆ ExtractPackageNamespace()

FString TextNamespaceUtil::ExtractPackageNamespace ( const FString &  InTextNamespace)

Given a text namespace, extract any package namespace that may currently be present.

Parameters
InTextNamespaceThe namespace currently used by the FText instance.
Returns
The extracted package namespace component, or an empty string if there was no package namespace component.

◆ GenerateDeterministicTextKey() [1/2]

FString TextNamespaceUtil::GenerateDeterministicTextKey ( UObject InTextOwner,
const FName  InTextPropertyName,
const bool  bApplyPackageNamespace = true 
)

◆ GenerateDeterministicTextKey() [2/2]

FString TextNamespaceUtil::GenerateDeterministicTextKey ( UObject InTextOwner,
const FTextProperty InTextProperty,
const bool  bApplyPackageNamespace = true 
)

Generate a deterministic text key based on the given object and property info.

Note
This key will be formatted like a GUID, but the value will actually be based on deterministic hashes.
Parameters
InTextOwnerThe object that owns the given TextProperty.
InTextPropertyThe text property to generate the key for.
bApplyPackageNamespaceIf true, apply the package namespace to the generated key hash (when USE_STABLE_LOCALIZATION_KEYS is true).

◆ GenerateRandomTextKey()

FString TextNamespaceUtil::GenerateRandomTextKey ( )

Generate a random text key.

Note
This key will be a GUID.

◆ GetTextIdForEdit()

void TextNamespaceUtil::GetTextIdForEdit ( UPackage InPackage,
const ETextEditAction  InEditAction,
const FString &  InTextSource,
const FString &  InProposedNamespace,
const FString &  InProposedKey,
FString &  OutStableNamespace,
FString &  OutStableKey,
TFunctionRef< FString()>  InTextKeyGenerator = &GenerateRandomTextKey,
const bool  bApplyPackageNamespace = true 
)

Called when editing a text property to determine the new ID for the text, ideally using the proposed text ID when possible (and when USE_STABLE_LOCALIZATION_KEYS is true).

Parameters
InPackageThe package to query the namespace for.
InEditActionHow has the given text been edited?
InTextSourceThe current source string for the text being edited. Can be empty when InEditAction is ETextEditAction::SourceString.
InProposedNamespaceThe namespace we'd like to assign to the edited text.
InProposedKeyThe key we'd like to assign to the edited text.
OutStableNamespaceThe namespace that should be assigned to the edited text.
OutStableKeyThe key that should be assigned to the edited text.
InTextKeyGeneratorGenerator for the new text key. Will generate a random key by default.
bApplyPackageNamespaceIf true, apply the package namespace to the generated text ID (when USE_STABLE_LOCALIZATION_KEYS is true).

◆ StripPackageNamespace()

FString TextNamespaceUtil::StripPackageNamespace ( const FString &  InTextNamespace)

Given a text namespace, strip any package namespace that may currently be present. This is similar to calling BuildFullNamespace with an empty package namespace, however this version will also remove the package namespace markers.

Parameters
InTextNamespaceThe namespace currently used by the FText instance.
Returns
The namespace stripped of any package namespace component.

◆ StripPackageNamespaceInline()

void TextNamespaceUtil::StripPackageNamespaceInline ( FString &  InOutTextNamespace)

Variable Documentation

◆ PackageNamespaceEndMarker

constexpr TCHAR TextNamespaceUtil::PackageNamespaceEndMarker = TEXT(']')
inlineconstexpr

◆ PackageNamespaceStartMarker

constexpr TCHAR TextNamespaceUtil::PackageNamespaceStartMarker = TEXT('[')
inlineconstexpr