mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit 'b715cc1f0fc52cdad1f951a10770aa8c522d107f'
This commit is contained in:
commit
2efc75f09a
@ -768,6 +768,10 @@ public class AttachmentController: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
print()
|
||||||
|
}
|
||||||
|
|
||||||
public required init(coder aDecoder: NSCoder) {
|
public required init(coder aDecoder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
@ -175,30 +175,6 @@ public func canTranslateText(context: AccountContext, text: String, showTranslat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func translateText(context: AccountContext, text: String, fromLang: String? = nil) {
|
|
||||||
guard !text.isEmpty else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if #available(iOS 15.0, *) {
|
|
||||||
let text = text.unicodeScalars.filter { !$0.properties.isEmojiPresentation }.reduce("") { $0 + String($1) }
|
|
||||||
|
|
||||||
let textView = UITextView()
|
|
||||||
textView.text = text
|
|
||||||
textView.isEditable = false
|
|
||||||
if let navigationController = context.sharedContext.mainWindow?.viewController as? NavigationController, let topController = navigationController.topViewController as? ViewController {
|
|
||||||
topController.view.addSubview(textView)
|
|
||||||
textView.selectAll(nil)
|
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
textView.removeFromSuperview()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let toLang = context.sharedContext.currentPresentationData.with { $0 }.strings.baseLanguageCode
|
|
||||||
let _ = context.engine.messages.translate(text: text, fromLang: fromLang, toLang: toLang).start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct TextTranslationResult: Equatable {
|
public struct TextTranslationResult: Equatable {
|
||||||
let text: String
|
let text: String
|
||||||
let detectedLanguage: String?
|
let detectedLanguage: String?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user