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.

    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>"

The message.i18n.updated events will always come after the event. Translations are generated asynchronously and so you should handle this in your user interface appropriately.

See Supported Language Codes for languages that are currently supported.

Last updated