简体   繁体   中英

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

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

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)

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);
}]; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM