translateMessage method

Future<void> translateMessage(
  1. Message message, {
  2. bool showTranslate = true,
})

Implementation

Future<void> translateMessage(Message message,
    {bool showTranslate = true}) async {
  try {
    Message msg = await ChatUIKit.instance.translateMessage(
      msg: message,
      languages: [ChatUIKitSettings.translateTargetLanguage],
    );
    Map<String, dynamic>? map = msg.attributes;
    map ??= {};
    if (showTranslate) {
      msg.setHasTranslate(true);
    } else {
      msg.setHasTranslate(false);
    }

    await ChatUIKit.instance.updateMessage(message: msg);
    _replaceMessage(msg);
  } catch (e) {
    debugPrint('translateMessage: $e');
  }
}