/ SDKs / Android
Chat SDKs Android v4
Chat SDKs Android
Chat SDKs
Version 4

Translate messages on-demand

Copy link

You can add a feature to your app to translate select messages into other languages. Using the openChannel.translateUserMessage() or the groupChannel.translateUserMessage() method, you can translate a text message already sent to a channel into the desired languages based on your own needs. To enable this feature, contact our sales team.

Note: Sendbird's on-demand message translation feature is powered by Google Cloud Translation API recognition engine. You can find the language codes supported by the engine in the translation engine page or visit the language support page in Google Cloud Translation.

val targetLanguages = listOf(
    "es",   // Spanish
    "de"    // German

// The USER_MESSAGE argument below indicates a UserMessage object which represents an already sent or received text message.
groupChannel.translateUserMessage(USER_MESSAGE, targetLanguages) { message, e ->
    if (message != null) {
        val map = message.translations
        val esTranslatedMessage = map["es"] // Spanish
        val deTranslatedMessage = map["de"] // German
        // ...

        // Show translations in the UI.