I want to use Google translate API from the iPhone.
What I found is : http://code.google.com/p/gdata-objectivec-client/
but in the list I cannot see the translate API.
Where can I find the library?
I want to use Google translate API from the iPhone.
What I found is : http://code.google.com/p/gdata-objectivec-client/
but in the list I cannot see the translate API.
Where can I find the library?
The Google Language API is provided as a web service. For non-javascript environments, you should be using JSON to communicate with Google's servers.
There doesn't seem to be an Objective-C wrapper to this functionality (like the ones you posted), so you'll have to roll your own. Thankfully, JSON is pretty easy to use on the iPhone.
I writed an objective-c wrapper for Google Translator service named PLTranslator. check it out at http://github.com/xhan/PLTranslator
The Google Language API is provided as a web service. For non-javascript environments, you should be using JSON to communicate with Google's servers.
There doesn't seem to be an Objective-C wrapper to this functionality (like the ones you posted), so you'll have to roll your own. Thankfully, JSON is pretty easy to use on the iPhone.
You can use Stig Brautaset’s JSON library (version 2.2), which provides functionality for parsing and generating JSON. The JSON response from Google Translate is well formatted with no line breaks, so you can use NSScanner too.
Once you get your Google keys just plug it into FGTranslator.
FGTranslator *translator = [[FGTranslator alloc] initWithGoogleAPIKey:@"your_google_key"];
[translator translateText:@"Bonjour!"
completion:^(NSError *error, NSString *translated, NSString *sourceLanguage)
{
if (error)
NSLog(@"translation failed with error: %@", error);
else
NSLog(@"translated from %@: %@", sourceLanguage, translated);
}];
© 2022 - 2024 — McMap. All rights reserved.