How to Actually Load Localised Locres Files in a Game?

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.

Hi RPG Hacker,

Your confusion is stemmed from the limitation that we can’t currently load Game text localization data while in the editor. You simply need to run your game outside of the editor. Try running the editor with your project information on the commandline plus -game. This will run in “game mode” and will attempt to load the game text localization.

As you discovered you can set your desired culture a few different ways. You can change the ini like you did but it needs to be in the DefaultEngine.ini. You can also pass -culture=“de-DE” on the cmdline while running the editor. I recommend this as the easiest iteration path. You can also change your OS region and format settings to German, which will also cause the engine to load German as long as no other forms of culture configuration were specified.

Lastly, the Japanese fallback is a bug we’ve recently fixed. The issue is we don’t have German translations for the editor, so when you attempted that it failed. It then decided to leave the current culture as it is currently set, unfortunately, there’s a unit test that runs on start up which temporarily changes the current culture to Japanese. Thus Japanese was the current culture. :slight_smile:

Thanks, that was actually quite helpful! Although unfortunately I’m still not quite there yet. This way at least I got the game to load my en locres file (where I altered the “Default Map” string slightly for testing purposes). However, I still can’t get it to actually load my de-DE locres file. At first I tried this:

"E:\UnrealEngine-4.3.1-release\Engine\Binaries\Win64\UE4Editor.exe" "E:\GitHub\Portfolio\KokkuEngine\KokkuEngine.uproject" -game -culture="de-DE"

This didn’t work and instead loaded the en locres file. I also tried replacing “de-DE” by “de_DE”, this made no difference. I also added the [Internationalization] segment to my DefaultEngine.ini, still no difference. Any idea what I’m doing wrong?

It shouldn’t be an issue but have you tried renaming your localization folder from de-DE to de?

In general, you’ll want to avoid specifying the region code unless you are actually providing translations specific for that region. This way a person who speaks German but is located in the US (de-US) will still get German translations.

Hey, this actually worked, thanks for the help! :slight_smile:
Just out of curiosity, though: Does this mean I can’t have specialised translations at all? (Like de_DE, de_AT etc.) Or are they just set up in a different way? Do I need a de locres before I can have a de_DE locres, or something like that?

Hmmm… I’m assuming it’s looking for de_DE folders instead of de-DE folders.

Good guess! I just tried it and it actually worked when I renamed my folder to de_DE! :slight_smile:
Is this intentional, though? In the UE4 Editor localization folder, there is a folder named “zh-CN”, so it uses a hyphen instead of an underscore. For the actual game a hyphen doesn’t work, though, it has to be an underscore. Is this a bug or an intentional behavior?

The Chinese folder is configured incorrectly. We’ve fixed this very recently.

But the code should/will be modified to look for either style, as we are in general tolerant of either style in other forms of input/configuration.