Skip to main content

TranslatorResultObserver

If you were looking for the method for use with Unity, see TranslatorResultObserver for Unity SDK.

Register the callback of the Player Network SDK Translate module, the game needs to process the callback function. For more information on the callback data structure, see BaseResult.

note

It is strongly recommended to perform registration in the startup function of the game application.

Function definition

C++ event handling (above V1.17)

// configure callback
void SetTranslatorResultObserver(FINTLTranslatorEvent& callback);
// get callback
FINTLTranslatorEvent& GetTranslatorResultObserver();

Unreal Engine event handling

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "INTLSDKObserver")
void OnTranslatorResult(FINTLTranslatorResult ret);
virtual void OnTranslatorResult_Implementation(FINTLTranslatorResult ret) {};

Code sample

C++ event handling (above V1.17)

// configure callback
FINTLTranslatorEvent translatorEvents;
translatorEvents.AddUObject(this, &OnTranslatorResult_Implementation);
UINTLSDKAPI::SetTranslatorResultObserver(translatorEvents);
// Remove callbacks
UINTLSDKAPI::GetTranslatorResultObserver().Clear();
void OnTranslatorResult_Implementation(FINTLTranslatorResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}

Unreal Engine event handling

void OnTranslatorResult_Implementation(FINTLTranslatorResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}