# Translate messages (/en/realtime-media/im/build/build-core-messaging/messages/translate-messages)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

<_PlatformTabsGroup groupMode="structured" canonicalPlatform="web" platforms="[&#x22;android&#x22;,&#x22;ios&#x22;,&#x22;web&#x22;,&#x22;flutter&#x22;,&#x22;react-native&#x22;,&#x22;unity&#x22;,&#x22;windows&#x22;]" showTabs="true">
  <_PlatformPanel platform="android">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="android" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `fetchSupportLanguages`, which queries the supported languages for translation.
    * `translateMessage`, which translates the text message after it is received.
    * `MessageBody.setTargetLanguages`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation]

    In both on-demand translation and automatic translation use-cases, call `fetchSupportLanguages` to query the supported languages for translation first:

    ```java
    ChatClient.getInstance().chatManager().fetchSupportLanguages(new ValueCallBack>{});
    ```

    ### On-demand translation [#on-demand-translation]

    When the recipient receives a text message, call `translateMessage` to translate the message:

    ```java
    List languageList = new ArrayList<>();
    languageList.add("en");
    ...
    ChatClient.getInstance().chatManager().translateMessage(
             message,
             languageList,
             new ValueCallBack() {});
    ```

    When the translation finishes, the translated message is stored in the message. Call `getTranslations` to get the translated message:

    ```java
    TextMessageBody body = (TextMessageBody)message.getBody();
    List infoList = body.getTranslations();
    ```

    ### Automatic translation [#automatic-translation]

    When creating a text message, the sender enables automatic translation by setting `MessageBody.setTargetLanguage` as the target language for translation:

    ```java
    TextMessageBody body = new TextMessageBody("The message content");
    body.setTargetLanguages(languageList);
    ```

    The SDK sends both the original message and the translated message. After the recipient receives the message, call `getTranslations` to retrieve the translated message:

    ```java
    TextMessageBody body = (TextMessageBody)message.getBody();
    List infoList = body.getTranslations();
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="ios">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="ios" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites-1]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-1]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `fetchSupportLanguages`, which queries the supported languages for translation.
    * `translateMessage`, which translates the text message after it is received.
    * `AgoraChatTextMessageBody.targetLanguages`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation-1]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation-1]

    In both on-demand translation and automatic translation use-cases, call `fetchSupportedLanguages` to query the supported languages for translation first:

    ```objc
    [AgoraChatClient.sharedClient.chatManager fetchSupportedLanguages:^(NSArray * _Nullable languages, AgoraChatError * _Nullable error) {

    }];
    ```

    ### On-demand translation [#on-demand-translation-1]

    When the recipient receives a text message, call `translateMessage` to translate the message. When the translation finishes, the translated message is stored in the message.

    ```objc
    // Only text messages can be translated.
    [AgoraChatClient.sharedClient.chatManager translateMessage:message targetLanguages:@[@"en"] completion:^(AgoraChatMessage *message, AgoraChatError *error) {
        // Get the translation.
        AgoraChatTextMessageBody* body = (AgoraChatTextMessageBody*)message.body;
        NSDictionary* translations = body.translations;
        }];
    ```

    ### Automatic translation [#automatic-translation-1]

    When creating a text message, the sender enables automatic translation by setting `AgoraChatTextMessageBody.targetLanguages` as the target language for translation:

    ```objc
    AgoraChatTextMessageBody* msgBody = [[AgoraChatTextMessageBody alloc] initWithText:@"Hello!!"];
    msgBody.targetLanguages = @[@"en",@"ja"];
    AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:@"to" from:@"from" to:@"to" body:msgBody ext:nil];
    [AgoraChatClient.sharedClient.chatManager sendMessage:message progress:nil completion:nil];
    ```

    The SDK sends both the original message and the translated message. Once the recipient receives the message, refer to the following code sample to get the translation:

    ```objc
    - (void)messagesDidReceive:(NSArray *)aMessages
    {
        for (AgoraChatChatMessage *msg in aMessages) {
            if (msg.body.type == AgoraChatMessageBodyTypeText) {
                // Get the translation
                AgoraChatTextMessageBody* body = (AgoraChatTextMessageBody*)message.body;
                NSDictionary* translations = body.translations;
            }
        }
    }
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="web">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="web" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites-2]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-2]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `getSupportedLanguages`, which queries the supported languages for translation.
    * `translateMessage`, which translates the received text message after it is received.
    * `languages` in `msgConfig`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation-2]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation-2]

    In both on-demand translation and automatic translation use-cases, call `getSupportedLanguages` to query the supported languages for translation first:

    ```javascript
    chatClient.getSupportedLanguages().then((res) => console.log(res));
    ```

    ### On-demand translation [#on-demand-translation-2]

    When the recipient receives a text message, call `translateMessage` to translate the message:

    ```javascript
    chatClient.translateMessage("hello", ["zh"]).then((res) => console.log(res));
    ```

    ### Automatic translation [#automatic-translation-2]

    When creating a text message, the sender enables automatic translation by setting `languages` in `msgConfig` as the target language for translation. The SDK sends both the original message and the translated message.

    ```javascript
    // Send the message.
    const options = {
      chatType: "singleChat",
      type: "txt",
      to: "userId",
      msg: "hello",
      msgConfig: { languages: ["zh"] }, // Set the target language for translation.
    };
    const msg = AgoraChat.message.create(options);
    chatClient.send(msg);

    // Occurs when the message is received.
    chatClient.addEventHandler("handlerId", {
      onTextMessage: (message) => {
        console.log("message", message.translations);
      },
    });
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="flutter">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="flutter" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites-3]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-3]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `fetchSupportedLanguages`, which queries the supported languages for translation.
    * `translateMessage`, which translates the text message after it is received.
    * `ChatTextMessageBody.targetLanguages`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation-3]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation-3]

    In both on-demand translation and automatic translation use-cases, call `fetchSupportLanguages` to query the supported languages for translation first:

    ```dart
    // Fetches the supported languages for translation.
    try {
      List list =
          await ChatClient.getInstance.chatManager.fetchSupportedLanguages();
    } on ChatError catch (e) {
    }
    ```

    ### On-demand translation [#on-demand-translation-3]

    When the recipient receives a text message, call `translateMessage` to translate the message:

    ```dart
    // Specifies the target language for translation
    List languages = ["en"];
    try {
      // Translate the received text message, which is in `textMessage`
      ChatMessage translatedMessage = await ChatClient.getInstance.chatManager
          .translateMessage(msg: textMessage, languages: languages);
    } on ChatError catch (e) {
    }
    ```

    When the translation finishes, the translated message is stored in the message. Get the translated message in `ChatTextMessageBody.translations`:

    ```dart
    ChatTextMessageBody body = translatedMessage.body as ChatTextMessageBody;
    debugPrint("translation: ${body.translations}");
    ```

    ### Automatic translation [#automatic-translation-3]

    When creating a text message, the sender enables automatic translation by setting `ChatTextMessageBody.targetLanguages` as the target language for translation:

    ```dart
    // Specifies the target language for translation.
    ChatMessage textMessage = ChatMessage.createTxtSendMessage(
      username: targetUser,
      content: content,
      targetLanguages: ["en"],
    );
    ```

    The SDK sends both the original message and the translated message. After the recipient receives the message, call `translation` to retrieve the translated message:

    ```dart
    ChatTextMessageBody body = receiveMessage.body as ChatTextMessageBody;
    debugPrint("translation: ${body.translations}");
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="react-native">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="react-native" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites-4]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-4]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `fetchSupportedLanguages`, which queries the supported languages for translation.
    * `translateMessage`, which translates the text message after it is received.
    * `ChatTextMessageBody.targetLanguages`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation-4]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation-4]

    In both on-demand translation and automatic translation use-cases, call `fetchSupportedLanguages` to query the supported languages for translation first:

    ```typescript
    // Fetches the supported languages for translation
    ChatClient.getInstance()
      .chatManager.fetchSupportedLanguages()
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    ### On-demand translation [#on-demand-translation-4]

    When the recipient receives a text message, call `translateMessage` to translate the message:

    ```typescript
    // Creates a text message. Only text messages can be translated.
    const msg = ChatMessage.createTextMessage(targetId, content);
    // Specifies the target language for translation.
    const languages = ["en"];
    // Translates the text message.
    ChatClient.getInstance()
      .chatManager.translateMessage(msg, languages)
      .then((result) => {
        console.log("success: ", result);
      })
      .catch((error) => {
        console.log("fail: ", error);
      });
    ```

    When the translation finishes, the translated message is stored in the message. Call `translations` to get the translated message:

    ```typescript
    const body = result.body as ChatTextMessageBody;
    console.log("translation: ", body.translations);
    ```

    ### Automatic translation [#automatic-translation-4]

    When creating a text message, the sender enables automatic translation by setting `ChatTextMessageBody.targetLanguages` as the target language for translation:

    ```typescript
    // Specifies the target language for translation.
    const languages: string[] = ["en"];
    const msg = ChatMessage.createTextMessage(
      targetId,
      content,
      ChatMessageChatType.PeerChat,
      { targetLanguages: languages }
    );
    ```

    The SDK sends both the original message and the translated message. After the recipient receives the message, call `translations` to retrieve the translated message:

    ```typescript
    const body = result.body as ChatTextMessageBody;
    console.log("translation: ", body.translations);
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="unity">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="unity" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites-5]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-5]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `FetchSupportLanguages`, which queries the supported languages for translation.
    * `TranslateMessage`, which translates the text message after it is received.
    * `TextBody.TargetLanguages`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation-5]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation-5]

    In both on-demand translation and automatic translation use-cases, call `FetchSupportLanguages` to query the supported languages for translation first:

    ```csharp
    // Fetches the supported languages for translation。
    SDKClient.Instance.ChatManager.FetchSupportLanguages(new ValueCallBack>(
         onSuccess: (list) =>
         {
             Debug.Log($"FetchSupportLanguages found total: {list.Count}");
             foreach (var lang in list)
             {
                 Debug.Log($"code: {lang.LanguageCode}, name:{lang.LanguageName}, nativename:{lang.LanguageNativeName}");
             }
         },
         onError: (code, desc) =>
         {
             Debug.Log($"FetchSupportLanguages failed, code:{code}, desc:{desc}");
         }
        ));
    ```

    ### On-demand translation [#on-demand-translation-5]

    When the recipient receives a text message, call `TranslateMessage` to translate the message:

    ```csharp
    SDKClient.Instance.ChatManager.TranslateMessage(msg, targetLanguages, new ValueCallBack(
     onSuccess: (dmsg) =>
     {
         Debug.Log($"TranslateMessage success.");
         TextBody tb = (TextBody)dmsg.Body;
         foreach(var it in tb.Translations)
         {
             Debug.Log($"Translate, lang:{it.Key}, result:{it.Value}");
         }
     },
     onError: (code, desc) =>
     {
         Debug.Log($"TranslateMessage failed, code:{code}, desc:{desc}");
     }
    ));
    ```

    ### Automatic translation [#automatic-translation-5]

    When creating a text message, the sender enables automatic translation by setting `TextBody.TargetLanguages` as the target language for translation:

    ```csharp
    Message msg = Message.CreateTextSendMessage(to, text);
    TextBody tb = (TextBody)msg.Body;
    tb.TargetLanguages = languageList;
    ```

    The SDK sends both the original message and the translated message. After the recipient receives the message, retrieve the translated message from `TextBody`:

    ```csharp
    TextBody tb = (TextBody)msg.Body;
    foreach(var it in tb.Translations)
    {
      Debug.Log($"Translate, lang:{it.Key}, result:{it.Value}");
    }
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="windows">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="windows" />

    Translation is a popular feature widely used in real-time chat apps. To enable translation, the Chat SDK has integrated the Microsoft Azure Translation API, which enables messages to be translated either when they are being sent or after they are received.

    The SDK supports translation in the following use cases:

    * On-demand translation, where the SDK translates the text message after the recipient receives it.
    * Automatic translation, where the SDK translates the text message when the sender sends it. The recipient receives both the original message and the translation simultaneously.

    ## Prerequisites [#prerequisites-6]

    Before proceeding, ensure that your development environment meets the following requirements:

    * Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic [real-time chat functionalities](../../../../get-started-sdk).
    * You understand the API call frequency limit as described in [Limitations](../../limitations).
    * Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support).
    * Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](../../../reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/v2).

    <CalloutContainer type="info">
      <CalloutDescription>
        Add-on fees are incurred if you use this feature. See [Pricing](..//en/realtime-media/im/reference/pricing#optional-add-on-fee) for details.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-6]

    The Chat SDK provides the following methods for implementing translation functionalities:

    * `FetchSupportLanguages`, which queries the supported languages for translation.
    * `TranslateMessage`, which translates the text message after it is received.
    * `TextBody.TargetLanguages`, which automatically translates the text message when it is being sent. When the recipient receives the message, it contains the message in both the original and target languages.

    ## Implementation [#implementation-6]

    This section introduces how to integrate translation functionalities into your project.

    ### Query the supported languages for translation [#query-the-supported-languages-for-translation-6]

    In both on-demand translation and automatic translation use-cases, call `FetchSupportLanguages` to query the supported languages for translation first:

    ```csharp
    // Fetches the supported languages for translation。
    SDKClient.Instance.ChatManager.FetchSupportLanguages(new ValueCallBack>(
         onSuccess: (list) =>
         {
             Debug.Log($"FetchSupportLanguages found total: {list.Count}");
             foreach (var lang in list)
             {
                 Debug.Log($"code: {lang.LanguageCode}, name:{lang.LanguageName}, nativename:{lang.LanguageNativeName}");
             }
         },
         onError: (code, desc) =>
         {
             Debug.Log($"FetchSupportLanguages failed, code:{code}, desc:{desc}");
         }
        ));
    ```

    ### On-demand translation [#on-demand-translation-6]

    When the recipient receives a text message, call `TranslateMessage` to translate the message:

    ```csharp
    SDKClient.Instance.ChatManager.TranslateMessage(msg, targetLanguages, new ValueCallBack(
     onSuccess: (dmsg) =>
     {
         Debug.Log($"TranslateMessage success.");
         TextBody tb = (TextBody)dmsg.Body;
         foreach(var it in tb.Translations)
         {
             Debug.Log($"Translate, lang:{it.Key}, result:{it.Value}");
         }
     },
     onError: (code, desc) =>
     {
         Debug.Log($"TranslateMessage failed, code:{code}, desc:{desc}");
     }
    ));
    ```

    ### Automatic translation [#automatic-translation-6]

    When creating a text message, the sender enables automatic translation by setting `TextBody.TargetLanguages` as the target language for translation:

    ```csharp
    Message msg = Message.CreateTextSendMessage(to, text);
    TextBody tb = (TextBody)msg.Body;
    tb.TargetLanguages = languageList;
    ```

    The SDK sends both the original message and the translated message. After the recipient receives the message, retrieve the translated message from `TextBody`:

    ```csharp
    TextBody tb = (TextBody)msg.Body;
    foreach(var it in tb.Translations)
    {
      Debug.Log($"Translate, lang:{it.Key}, result:{it.Value}");
    }
    ```

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>
</_PlatformTabsGroup>
