
Text translation (localization) system in Unreal engine
- Tutorial

Hello, my name is Dmitry. I make computer games on the Unreal Engine as a hobby. A couple of days ago I wrote an article about the quest and dialogue editor. Well, since you wrote dialogs for the game, you probably want to translate them into other languages. In this article I will describe how the module works designed to localize text in the Unreal engine.
So first you need to enable its Editor Preferens → Experemental → Localization Dasbord. Unfortunately, the module is still experimental.

After that, you need to restart Unreal engin. Once you do this, the Localization Dasbord item will appear on the Windows menu. We go into it and see this.

Here you need to add a new culture (Add new culture) and select the Native language, this is the language in which your text is written in my case it is English you will probably have Russian.
Now you need to determine where the Unreal engine will extract text.
First, it must be said that the Unreal engine will extract text from all variables of which type FText (in fact, this is the main difference between this type and FString). If you have a FText variable but don’t want the Unreal engine to translate this text, you can disable it:

By turning on the Gather from text files switch, we can extract text from c ++ files. By default, the text will be extracted from ".h", ".cpp", ".ini" Naturally, the variables in these files should be defined as FText in C ++, this is done like this:
/* Top of File */
#define LOCTEXT_NAMESPACE "Your Namespace"
...
FText TestHUDText = LOCTEXT( "Your Key", "Your Text" )
...
#undef LOCTEXT_NAMESPACE
/* Bottom of File */
or so
FText TestHUDText = NSLOCTEXT( "Your Namespace", "Your Key", "Your Text" )
By turning on the Gather from Packages switch, the Unreal engine will extract text from assets. The default is ".uasset" and ".umap".
Everything looked like this for me:

Now you can click the "Gather text" button and the Unreal engine will create localization files. You can translate either directly into the Unreal engine or import the translation file and use the ".po" file editor. I used Poedit.
Important: After you complete the translation, do not forget to click the “Compile Text” button. And then the translation will not appear in the game.
To switch the text in the game, you can use the function:
void AHUD_StoryGraph::ChangeLocalization(FString target)
{
FInternationalization::Get().SetCurrentCulture(target);
}
As target you need to substitute the abbreviations en - English, ru - Russian and so on.
Important: To see the translation, the game must be launched in Standalon Game mode, if you run it in export then you will not remove the translation.
When packing the game, go to Project setting → Packing and select Include prerequisites, select the languages that you will include in the game and change the Intarnacialization support parameter from English only to All.

Actually everything, now you can localize your game in all languages of the world.
Here is an example