Support for localizing data-driven text?

For various reasons we’re storing data about certain assets outside of Unreal, but we’d like to utilize Unreal’s localization tools for them, as there’s no point trying to invent a replacement for FText and ICU just for these things.

What I would like to know is if it’s possible to generate or hand-build either localization format (.archive, .manifest, .po) from outside Unreal and have it generate a .locres file, that can then be used for referencing localized strings programatically.

As an example, an asset may have a DisplayName property, keyed in our system by “data/133/DisplayName”, which is generated based on the type definition and the ID (133) of the property. I’ve been playing around with manually putting these into .archive, .manifest, and .po files, trying to get a .locres file out of it, so far without success. (Regular GatherText extraction from code and assets work, so I’m pretty sure the overall setup is right)

I’m also curious if I’ll be able to initialize an FText property with this key in runtime and have it look up the correct text in the .locres file, once I’ve gotten it generated. I know there’s no such constructor for FText, but you get what I’m after.

UPROPERTY()
FText DisplayName;

int id = myData.ID;
DisplayName = FText::FromString(FString::Format(TEXT("data/%d/DisplayName"), id));

Cheers,

Hi Judge,

  1. Idk how you’re storing your data but gathering from non-unreal files isn’t a huge deal. The current source code gatherer is really a plain text gatherer. If you stored your data in LOCTEXT format, similar to how it is used in source files, it would be able to gather from your non-unreal file. Otherwise, I would clone the source code gatherer commandlet and tweak it to be able to read your format, and add a new entry for your new gatherer in your loc configuration.
  2. You want to use FText::FindText(). It’s not something we advertise as it’s not very often its use is valid but it’s exactly what you’re looking for.

Excellent! Dumping our strings into LOCTEXT seem like the simplest option for us. And thanks for the FindText reference, I can’t believe I didn’t find it while reading through the header file.