Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
Message
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

Translate messages on-demand

You can add a feature to your app to translate select messages into other languages. Using the channel.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 message on-demand 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. You can also visit the language support page in Google Cloud Translation.

const targetLanguages: string[] = ['es', 'de']; // Spanish and German.
const message = await channel.translateUserMessage(USER_MESSAGE, targetLanguages);

const esTranslatedMessage = message.translations['es']; // Spanish.
const deTranslatedMessage = message.translations['de']; // German.