/ SDKs / Flutter
Chat SDKs Flutter v4
Chat SDKs Flutter
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 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.

// The USER_MESSAGE argument below indicates a UserMessage object
// which represents an already sent or received text message.
try {
  final message = await channel.translateUserMessage(
    USER_MESSAGE, ['es', 'de']
  final esTranslatedMessage = message.translations['es']  // Spanish
  final deTranslatedMessage = message.translations['de']  // German
} catch (e) {
  // Handle error.
// Display translations in the UI.