Localization switch in runtime works only one time

Hi there!

I’ve got strange behavior with the localization system in UE4 (and 5).
I’m trying to switch the language of my game in runtime. I have two languages (English and Russian) completely filled in Localization Dashboard.

I have an UI with two buttons, each one makes a simple call of the Set Culture function with the correct key.

And this is where things get interesting. It works only once in Editor and in Shipping build. I can switch from the current language to the new one, but not back to the previous one. I’ve got all the correct calls in FInternationalization::SetCurrentCulture, but the game’s text fields are unchanged.

For some reason, it works perfectly if I launch a standalone preview from the editor.
It also works if I restart the game while using the “save to config” check in Set Culture - so the culture is saved correctly and updated after the restart. But not in runtime.

Is this the expected behavior for the localization system? Am I trying to do something that I shouldn’t be doing?

I really appreciate any help you can provide.

Example project in 5.1 with basic 3 button change of language

LocalTest.zip (103.8 KB)

The part of setting the language

void UGameInstanceEX::SetLanguage(FString Language) {	
	FInternationalization::Get().SetCurrentLanguageAndLocale(Language);
	
	FCultureRef currentLang = FInternationalization::Get().GetCurrentLanguage();
	FString displayName = currentLang.Get().GetDisplayName();


	bool exists = UGameplayStatics::DoesSaveGameExist("GameSettings", 0);
	if (!exists)
		SaveGame = Cast<USaveGameSettings>(UGameplayStatics::CreateSaveGameObject(USaveGameSettings::StaticClass()));
	else
		SaveGame = Cast<USaveGameSettings>(UGameplayStatics::LoadGameFromSlot("GameSettings", 0));

	SaveGame->Language = Language;
	UGameplayStatics::SaveGameToSlot(SaveGame,"GameSettings", 0);

}


FString UGameInstanceEX::LoadLanguage() {
	FString ReturnLang = "";
	if (SaveGame = Cast<USaveGameSettings>(UGameplayStatics::LoadGameFromSlot("GameSettings", 0))) {
		FInternationalization::Get().SetCurrentLanguageAndLocale(SaveGame->Language);
		ReturnLang = SaveGame->Language;
	}
	return ReturnLang;
}
1 Like

Okay, spent another hour on this. Your project works, mine doesn’t. And after trying everything, I’ve found the difference. My default language was not English. I’ve been using “temporary” language as a basic one, so I can freely change both my translations (as far as I’ve read yesterday, I don’t need this anymore). So, I’ve removed it and made English my default language. And now it just works as expected. Wow :smiley:

Thank you.