Reputation: 1238
I have to translate the data coming from API in my app. For which I need to integrate Google Translate or something that can translate the data that is coming from backend.
How do I start coding this?
Upvotes: 0
Views: 5207
Reputation: 31645
There is no specific SDK for the iOS platform for Google translation.
However, you could achieve it by "manually" requesting the translation API(s). For more information, check the Google Cloud Translation API Documentation.
Furthermore: Using ROGoogleTranslate, might save some time, therefore you would be able to do it like this:
var params = ROGoogleTranslateParams(source: "en",
target: "de",
text: "The sentence to be translated")
let translator = ROGoogleTranslate(with: "API Key here")
translator.translate(params: params) { (result) in
print("Translation: \(result)")
}
Upvotes: 2
Reputation: 2470
You can use google Translator URL to translate text inside your Application. Follow the example.
let selected_language = "en"
let target_language = "hi"
let YourString = "hello"
let GoogleUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + selected_language + "&tl=" + target_language + "&dt=t&dt=t&q=" + YourString
After creating the GoogleUrl
perform a Get Request from this URL using urlSession
or Alamofire
this url will return you json responce of translated text.
Upvotes: 2