I want to test localization in my UE4 game. In this particular case I’m trying out German localization. After some trial and error I have finally gotten UE4 to extract all the FTexts from my game into a game.archive file lying inside Content/Localization/Game/de-DE. For testing purposes I made an FText property and assigned the value “Default Map” to it. UE4 correctly exported this text to the game.archive file. This is what it looks like after translation:
[...]
{
"Namespace": "Level Names",
"Children": [
{
"Source":
{
"Text": "Default Map"
},
"Translation":
{
"Text": "Standard-Map"
}
},
{
"Source":
{
"Text": "New Level"
},
"Translation":
{
"Text": "Neues Level"
}
}
]
}
[...]
I ran the commandlet batch file again to get the updated game.locres file. I looked into it with a hex editor to make sure it worked in the first place and actually found my “Standard-Map” string somewhere in there (encoded with 2 bytes per character). To test the translation, I added a “Print String” to my level blueprint’s Tick event and passed to it the “Default Map” FText, converted to an FString (since there is no verison of Print String that supports FTexts directly).
Now this is where I am stuck. No matter what I do, “Default Map” just always stays as “Default Map” on the screen. It just never seems to load any of the strings from the translation files. I’ve even tried changing the “Default Map” translation inside the en/game.archive into something and it didn’t make any difference, still just “Default Map”. I started UE4 Editor with the -leet argument to make sure the Text goes through the localization pipeline at all and it turned into “D3f@ul7 M@p” as it should. I have no idea, what I’m doing wrong, but UE4 just doesn’t want to load any of my locres files.
I tried adding this code to my DefaultGame.ini:
[Internationalization]
LocalizationPaths=../../../../GitHub/Portfolio/KokkuEngine/Content/Localization/Game
Culture=de-DE
It had no effect. I also tried adding the same lines to my DefaultEngine.ini. Still no effect. I even tried replacing “Culture=de-DE” in both files by “Culture=ja” for testing purposes, since Japanese translation files always come with
UE4. Strangley, even that had no effect at all and UE4 Editor was still in English.
Before all of this, I even tried setting the culture directly through FInternationalization. I called
FInternationalization::Get().SetCurrentCulture(TEXT("de_DE"));
somwhere inside my C++ code. This was actually the strangest of all as it set my whole UE4 Editor to Japanese for some reason. How did it even confuse “de_DE” with “ja”? Or did it just pick Japanese because that happend to be the last translation on my list of available translations inside UE4 Editor? Anyways, removing that line from my C++ code restored my UE4 Editore back to English.
At this point I’m pretty lost. Just how can I get UE4 to load any of my locres files into the game and then display the translated strings? I have no idea what I could be doing wrong. Any ideas? Are the locres files maybe not found in the first place? The “…/…/…/…/GitHub/Portfolio/KokkuEngine/Content/Localization/Game” is actually a path that UE4 generated for me (it’s a path relative to UE4 Editor), so I’d assume that that works, but maybe I’m wrong here? Any help is appreciated.