Save culture to ini file

Hello all !

I may be stupid but after reading lot of topics and docs, I’m unable to find the C function I have to use in order to change the “Culture” key in the engine.ini.

It would be really cleaner than a “load game from slot” …

I read in another post that it’s possible :

The culture used at runtime is either loaded from your Engine.ini file (set as the Culture key->value under the Internationalization section), or automatically detected based on your OS culture settings. You can also override this by passing -culture=bla on the command line when starting your game.

Thanks for reading !

Although this post is now over 4 years old and posted under Unreal Engine version 4.10, it is one of the first I stumbled upon when trying to solve the very same problem. As I was able to solve it in a very simple manner, I would like to share it here. Although, as mentioned later, this solution might only work with Unreal Engine version >4.22.

Disclaimer:

You will need C++ for this, however, you basically only need to write a couple lines of code.

Tl;Dr

Include the the following library:

Kismet/KismetInternationalizationLibrary.h

Afterwards, changing and saving the current language is easily done by the following line of code:

UKismetInternationalizationLibrary::SetCurrentLanguageAndLocale(Target, true);

Note the boolean at the end, which, if turned to true, will save the new language to the .ini file. This function is also available in Blueprint, however, the boolean is not exposed.

Longer version with Blueprint exposure

Create a C++ class (In the content browser go to “C++ Classes” and right click. Then choose “New C++ Class”) and derive from “BlueprintFunctionLibrary.h” (in the pop-up window check the “Show All Classes” box in the upper right hand corner and search for “BlueprintFunctionLibrary.h”). Then click “Next” and give it a name.
Then copy the function (or the whole source files) from the following header and source file.

Header file:

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Rico_BlueprintFunctionLibrary.generated.h"

/**
*
*/
UCLASS()
class VOELKERBALL_API URico_BlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
  GENERATED_BODY()

public:
  UFUNCTION(BlueprintCallable, meta = (DisplayName = "Change Localization"), Category = "Locale")
  static void ChangeLocalization(FString Target);
};

Source file:

#include "Rico_BlueprintFunctionLibrary.h"
#include "Kismet/KismetInternationalizationLibrary.h"

void URico_BlueprintFunctionLibrary::ChangeLocalization(FString Target)
{
  UKismetInternationalizationLibrary::SetCurrentLanguageAndLocale(Target, true);
}

PS: I am using Unreal Engine v4.25. Apparently this functionality was added in version 4.22.