Api Google translate

How can use Google translate api in swift5 for choosing language in the first?

This is likely off topic for Swift Forums but it’s hard to suggest a better venue without more details. First of all, what platform are you developing for? iOS? macOS? Some other Apple platform? Or some non-Apple platform, like Linux or Windows?

Also, I’m unable to parse this:

for choosing language in the first

Can you clarify?

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

I need Google translate api for iOS app by using swift

I presume you're referring to Google's translation API, which is a REST based API - so using swift to interact with it would be very much akin to using swift to interact with any other REST based API at a high level.

On a more specific level, there's an article I spotted (via Google search) at AppCoda that specifically walks you through the components and pieces for the swift code to interact with their REST API - and specifically to using that API for language detection, which it sounds like you're asking for.

There's a StackOverflow question (w/ multiple answers) about generally making a REST API call from Swift that's been around a while and is a pretty good short-synopsis read, but the gist of the flow is:

  • construct an appropriate URL
  • set up URLSession to make the request
  • within that, pass in a closure to deal with the response
  • when you've got that set up, activate the request to start its processing

When use this code
When click on /detect language/It freeze at "please wait while text language is being detected ...."
When click on /yes , fetch supported language / it freeze at
"Please wait while translation supported languages are being fetched...."
And in /Apis & Service : Dashboard : Filter /
The requests for cloud translation API increase but no translate in fact

Please help

I think to help you further, you'll need to do a bit more diagnostic and explanation on your side - at least where it comes to using Swift to do this. The problem you're generically describing is that you are successfully making a connection, and you can see that Google registered the API request through their dashboard, but that you're not getting a response.

Without any code to show, there's little anyone on this forum could do to help you - and while I'm sure some folks around here know and use the Google API's, this is a forum more for swift than how those APIs work.

That said, as a general debugging tip, a way forward would be to 1) understand what's supposed to happen, 2) follow along with what did happen, and 3) look for where those two things diverge, and then see if there's any additional clues or details you can pick up by using the debugger in Xcode, adding logging or even print statements into your code so you can see what was executed or not. How that translates into what's updated in your user interface is another level of abstraction, and describing that doesn't help anyone else help you with your code.

Assuming you used something like the stack overflow code, did the closure for the response ever get a call back? Maybe put an NSLog, os_log or print statement in there to find out, and expose the raw response object so you can see what it said.

There are also tools, such as Charles Proxy, which can help by capturing the HTTP request and response as they're made, and showing you what happened within them. Setting up Charles Proxy takes more work and has it's own complications and learning, but if you're doing a lot of REST API work from iOS or macOS, it can be invaluable.

Terms of Service

Privacy Policy

Cookie Policy