diff --git a/ReaderTranslator/Components/ServiceProvider.swift b/ReaderTranslator/Components/ServiceProvider.swift index 34b5237..94b6f68 100644 --- a/ReaderTranslator/Components/ServiceProvider.swift +++ b/ReaderTranslator/Components/ServiceProvider.swift @@ -19,6 +19,17 @@ class ServiceProvider: NSObject { return } - store.translateAction = .translator(text: text) + self.store.translateAction = .translator(text: text) + openText(text: text) + } + + private func openText(text: String) { + let defaultUrl = "https://translate.google.com" + guard var urlComponent = URLComponents(string: defaultUrl) else { return } + urlComponent.queryItems = [ + .init(name: "text", value: text) + ] + + if let url = urlComponent.url { Safari.openSafari(url) } } }