translateText

Introduction

Translate Text

Message translation currently only supports manually calling the API to translate text message content. Non-text content such as images, videos, files, voice messages, and custom messages are not supported for translation.

Works since version 1.0.25

Parameter details

Parameter name Parameter type Required Description
texts string[] yes Text.
targetLanguage string yes Text Translation Language Support.
sourceLanguage string no It can be set to a specific language or 'auto'. 'Auto' means automatic recognition of the source language. Empty value defaults to 'auto'.

Returned template

V2TimValueCallback<Map<String, String>>

{
    code : int
    desc : String
    data : Map<String, String>
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.
data Map< String, String > Result list of translating text operation.

Code example


import { TencentImSDKPlugin } from 'react-native-tim-js';

const TranslateTextresponse = await TencentImSDKPlugin.v2TIMManager
    .getMessageManager()
    .translateText(
        [texts],
        targetLanguage,
        sourceLanguage || ''
    );
if (TranslateTextresponse.code === 0) {

}

results matching ""

    No results matching ""