Callback for Translation (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
// Add callback
public static void AddTranslatorObserver(OnINTLResultHandler<INTLBaseResult> callback);
// Remove callback
public static void RemoveTranslatorObserver(OnINTLResultHandler<INTLBaseResult> callback);
Code sample
// Add callback
public void AddTranslatorObserver()
{
INTLAPI.AddTranslatorResultObserver(OnTranslatorResultEvent);
}
// Remove callback
public void RemoveTranslatorObserver()
{
INTLAPI.RemoveTranslatorResultObserver(OnTranslatorResultEvent);
}
// Callback handling
private void OnTranslatorResultEvent(INTLTranslatorResult result)
{
if (result.MethodId == (int)INTLMethodID.INTL_TRANSLATOR_TRANSLATE)
{
// Handle translation result
// INTLTranslatorResult's TranslatorResp content demo is as follows:
// Success
{
"msg":"success",
"ret":0,
"seq":"11-0ce2f314-8771-4d97-955b-66f972dc0706-1723023056-7",
"translator_rsp":{
"debugInfo":null,
"message":"Success",
"result":[
{
"id":"c5b2802a287f58c9ce250f8c77fc6029",
"output":"xxxx",
"text":"xxxx"
}
],
"retCode":"0"
}
}
}
}