Add translation API

This commit is contained in:
Ilya Laktyushin
2022-01-28 21:00:56 +03:00
parent b618777883
commit 4c36a2172f
7 changed files with 66 additions and 13 deletions

View File

@@ -1046,9 +1046,10 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
})]
if canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages) {
let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages)
if canTranslate {
actions.append(ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuTranslate, accessibilityLabel: strings.Conversation_ContextMenuTranslate), action: {
translateText(context: context, text: text)
translateText(context: context, text: text, fromLang: language)
}))
}