Translation
Have seamless cross-language conversations by specifying source and target language codes in the message metadata, ensuring real-time translations between speakers of different languages
You can provide a chat experience between speakers of two different languages by simply specifying the language codes when sending a message and using the i18n
payload of a message to render translations in your chat application. You must set sourceLanguageCode
and targetLanguageCodes
in the metadata
of the message.
chat.sendMessage({
channelId: "alpha",
content: "<p>Good morning, how are you?</p>",
metadata: {
sourceLanguageCode: "en",
targetLanguageCodes: ["es", "zh"]
},
});
An message.i18n.updated
event will be published for each completed translation and the message will have a populated i18n
key, that in our example will look like this:
{
"es": {
content: "<p>¿Buenos días cómo estás?</p>"
},
"zh": {
content: "<p>早上好你好嗎?</p>"
}
}
Last updated