You can use a code similar to this one to localize (not convert directly) you message to a string if the message contains variables inside:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
message_to_string := class(creative_device):
# Localizable message function that takes a player parameter and returns a formatted message
MyMessage<localizes>(Player:player) : message = "Player: {Player}"
# Editable button device that can be configured in the UEFN editor
@editable
MyButton : button_device = button_device{}
# Override function that runs when the device starts in a running game
OnBegin<override>()<suspends>:void=
# Subscribe the OnButtonPressed function to the button's interaction event
MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)
# Function called when the button is pressed by an agent
OnButtonPressed(Agent : agent) : void =
# Get all players currently in the playspace
AllPlayers := GetPlayspace().GetPlayers()
# Check if there is at least one player and assign it to FirstPlayer
if (FirstPlayer := AllPlayers[0]):
# Call MyMessage function with the first player to generate a localized message
MessageWithPlayer := MyMessage(FirstPlayer)
# Convert the message to a string using Localize()
MyString : string = Localize(MessageWithPlayer)
# Print the converted string to the UEFN log
Print("Converted message to string: {MyString}")
Keep in mind that if you are using player names, for instance, you won’t get the real player name but something like this:
This happens becasue player names are not available as a string in UEFN.
If the message is only text, you can use this code instead:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
message_to_string := class(creative_device):
# Localizable message function that takes a player parameter and returns a formatted message
MyMessage<localizes> : message = "Hello World!"
# Editable button device that can be configured in the UEFN editor
@editable
MyButton : button_device = button_device{}
# Override function that runs when the device starts in a running game
OnBegin<override>()<suspends>:void=
# Subscribe the OnButtonPressed function to the button's interaction event
MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)
# Function called when the button is pressed by an agent
OnButtonPressed(Agent : agent) : void =
MyString : string = Localize(MyMessage)
Print("Converted message to string: {MyString}")
That’s correct, Localize() uses the language configured on the application (and since verse runs on server, it is always english)
There is no Localize(Message, "en-US"), Localize(Message, "pt-BR") and so on.
Localized messages are not meant to be post-processed (edited, trimmed or so on), it is supposed to be static.
For line breaks you should enable Text Wrap on the Text Block Widget. In verse it has not this option but you can workaround by making a single text widget with verse field for that… That approach is also way better than manipulating character sizes in verse from scratch (since it has lots of bugs, characters are not all same sizes and so on)