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

By using the channel.translateUserMessage() method, you can allow users to translate text messages to other languages. You can implement a real-time translation feature to your client app and also allow only a selected message to be translated to a preferred language.

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.