I am making a game and have two languages you can pick from. How can i code or blueprint this so it can switch from French to English?
If you have no experience with localization I suggest you to start here https://docs.unrealengine.com/latest/INT/Gameplay/Localization/ . Hope this helps!
If you want to Change the language, you have to use a Little bit c++. At least in Version 4.10 (my first Project).
https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Internationalization/FInternationalization/index.html
With that i managed to make a blueprint library. From my menu i call then the node that i have created in c++. It is not that hard.
Hi LeannePI
Possible solution here for you.
File - New C++ Class
Choose parent class - Blueprint Function Library, hit next
Give it a name ( SwitchLanguage )
Dont forget to replace where YOURPOROJECTNAME with your correct info.
SwitchLanguage.h
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SwitchLanguage.generated.h"
/**
*
*/
UCLASS()
class YOURPROJECTNAME_API USwitchLanguage : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/* Change Localization at Runtime. */
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Change Localization"), Category = "Localization")
static void changeLocalization(FString target);
};
SwitchLanguage.cpp
#include "SwitchLanguage.h"
#include "YOURPROJECTNAME.h"
void USwitchLanguage::changeLocalization(FString target)
{
FInternationalization::Get().SetCurrentCulture(target);
}
Once done hit compile.
Now you have a node inside blueprint to switch your language,
Also don’t forget to test, you need to play standalone game
FWIW, more recent versions of UE4 have UKismetInternationalizationLibrary
which provides a solid implementation (including persisting the change to the correct config file) for changing the language and locale (including setting asset group cultures).