Localized FText to native culture

Is there any way (C++ or BP) to get the native culture version of an FText regardless of the current culture?

Let’s say I have a variable “alignment” with combobox FText options “left” and “right” (native culture English). If I would set the culture to German (de) for example I would have the options “links” and “rechts” in the UI, all as expected. However, the value the user selects is later being parsed to a JSON string and processed elsewhere. To make this processing easier I would prefer the JSON to always use the native English words. Hence the questions whether there is any way to transform an FText to the native culture in the background so I can cast it to FString/JSON.

1 Like

I’d say it’s a bad idea to use localizable user-facing text in your backend/logic.

Use a data table with IDs (the English text you want or anything you want to export to a JSON) that won’t change and values that will be localizable. Populate UI elements with values from this data table (they will depend on the culture), and after the user selects an item, find the ID by matching the selected item from the UI element against data table values: both will be localized and in sync. That way you’ll have an ID that won’t depend on the culture.

(I guess you could use any ordered collection of ID-value pairs, not only a data table.)

In fact, it’s a pretty standard workflow: your player selects something in the UI and you want to update something based on their selection. It’d be nice if Unreal UI elements accepted not just values but pairs of keys and values, and provided GetSelectedKey method on top of the GetSelectedItem.

You could also have an ordered collection of values and another ordered collection of IDs, and use GetSelectedID but that would mean that you’d have to keep those two collections in sync manually, and that’s a pain in my opinion.