Skip to main content

Callback of the translation module (TranslatorResultObserver)

If you are using the Unity engine, see Unity SDK's TranslatorResultObserver.

Register the callback for the Player Network SDK translation module. The game needs to register the callback for processing.For more information about the callback data structure, see BaseResult.

note

It is strongly recommended that games register during the application start-up function.

Function definition

C++ Event Handling Method (V1.17 and above)

// 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 example

C++ Event Handling Method (V1.17 and above)

// Configure callback
FINTLTranslatorEvent translatorEvents;
translatorEvents.AddUObject(this, &OnTranslatorResult_Implementation);
UINTLSDKAPI::SetTranslatorResultObserver(translatorEvents);
// Clear callback
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);
}