Is it possible to use the Google Translate api with iOS?
Asked Answered
P

2

6

How do I use the google translate API with iOS 6.0? I have tried googling the documentation and tried to research it, but I can't find anything that is updated since google made the api to be no longer free.

The only thing I have been able to find was this, but it didn't really help much because I need to use the api key that I have, but I have no idea how to.

http://www.raywenderlich.com/1448/how-to-translate-text-with-google-translate-and-json-on-the-iphone

Plexiglas answered 6/12, 2012 at 23:15 Comment(3)
I wasn't the downvoter but at a guess it's because the question is extremely broad — making it not all that good a fit for the Q&A format of StackOverflow — and because you don't make it particularly clear what you've already tried and what results you found.Saline
I updated it with a link to the only thing I found for iOS and the api. Does that make it betteR?Plexiglas
@RobSmith Were you able to solve this?Mieshamiett
T
4

This seems up to date: https://developers.google.com/translate/v2/getting_started

(completely meta: Oops! Your answer couldn't be submitted because: body must be at least 30 characters; you entered 23)

Tigges answered 7/12, 2012 at 17:22 Comment(4)
Thanks! I used this URL - NSString url = [NSString stringWithFormat:@"googleapis.com/language/translate/…", textEscaped, langStringEscaped]; where MYKEY is my api key, but I get this error. Connection Error: Error Domain=NSURLErrorDomain Code=-1000 *bad URL UserInfo=0x1d5b6370Plexiglas
I noticed there was a space in the url and now I get response status 0Plexiglas
Response status 0 and no NSError? Sounds odd.Tigges
I go this which I would assume means the url is working, but that I have reached the limit.{ "error": { "errors": [ { "domain": "usageLimits", "reason": "dailyLimitExceeded", "message": "Daily Limit Exceeded" } ], "code": 403, "message": "Daily Limit Exceeded" } }Plexiglas
T
2

Yes, it is. Once you get your Google key, just plug it into FGTranslator. Note, generate a "server" key, since the Google Translate API does not currently support iOS keys.

It's just a one-line call to the translate function after that.

FGTranslator *translator = [[FGTranslator alloc] initWithGoogleAPIKey:@"your_google_key"];

[translator translateText:@"Bonjour!" 
               completion:^(NSError *error, NSString *translated, NSString *sourceLanguage)
{
    NSLog(@"translated from %@: %@", sourceLanguage, translated);
}]; 
Thickness answered 21/8, 2014 at 18:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.