Reputation: 55
I am newbie in iOS I make an application that contain Language translate feature, so I use Bing API for it and use FGTranslator from Github.
But it translate French to English but I want to make an selection to user like as user can select language like as French
,Spanish
etc then how convert language from english to Spanish form FGTranslator Please give me Solution for it.
Here FGTranslator
language converter method look like as
[self.translator translateText:@"Helo How are You"
completion:^(NSError *error, NSString *translated, NSString *sourceLanguage)
{
if (error)
{
[self showErrorWithError:error];
[SVProgressHUD dismiss];
}
else
{
NSString *fromLanguage = [[self currentLocale] displayNameForKey:NSLocaleIdentifier value:sourceLanguage];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:fromLanguage ? [NSString stringWithFormat:@"from %@", fromLanguage] : nil
message:translated
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
NSLog(@"STERING %@",translated);
[SVProgressHUD dismiss];
}
}];
Here how I can set different language from user selection.
Here i write a method for it then i got error like as FGTranslatorErrorDomainerror 1
.
Please help me
I write a method like as
[self.translator translateText:self.textView.text withSource:@"en" target:@"js" completion:^(NSError *error, NSString *translated, NSString *sourceLanguage) {
if (error)
{
[self showErrorWithError:error];
[SVProgressHUD dismiss];
}
else
{
NSLog(@"Translated Text %@",translated);
}
}];
Here i write en
for english and js
for Japanese Please help me.
Upvotes: 3
Views: 609
Reputation: 8371
It seems like you're using the wrong name for the translation. The method supportedLanguages:
returns languages like English
, French
and so on, but you're using en
and fr
to translate them.
So this should work:
[self.translator translateText:self.textView.text withSource:@"English" target:@"French" completion:^(NSError *error, NSString *translated, NSString *sourceLanguage) { /* ... */ }];
Upvotes: 1