| Index: ios/web_view/shell/translate_controller.m
|
| diff --git a/ios/web_view/shell/translate_controller.m b/ios/web_view/shell/translate_controller.m
|
| index e28d0089282d7c3dfb9a593a323ecc0a0a81c229..9cbf875670c8aa96516d32f7e54c380e8a797057 100644
|
| --- a/ios/web_view/shell/translate_controller.m
|
| +++ b/ios/web_view/shell/translate_controller.m
|
| @@ -14,54 +14,60 @@
|
| @interface TranslateController ()
|
| // Action Sheet to prompt user whether or not the page should be translated.
|
| @property(nonatomic, strong) UIAlertController* beforeTranslateActionSheet;
|
| -// Manager which performs the translation of the content.
|
| -@property(nonatomic, strong) id<CWVTranslateManager> translateManager;
|
| @end
|
|
|
| @implementation TranslateController
|
|
|
| @synthesize beforeTranslateActionSheet = _beforeTranslateActionSheet;
|
| -@synthesize translateManager = _translateManager;
|
|
|
| - (void)dealloc {
|
| [_beforeTranslateActionSheet dismissViewControllerAnimated:YES
|
| completion:nil];
|
| }
|
|
|
| -#pragma mark CWVTranslateDelegate methods
|
| +#pragma mark - CWVTranslationDelegate methods
|
|
|
| -- (void)translateStepChanged:(CRIWVTransateStep)step
|
| - manager:(id<CWVTranslateManager>)manager {
|
| - if (step == CRIWVTransateStepBeforeTranslate) {
|
| - self.translateManager = manager;
|
| - self.beforeTranslateActionSheet = [UIAlertController
|
| - alertControllerWithTitle:nil
|
| - message:@"Translate?"
|
| - preferredStyle:UIAlertControllerStyleActionSheet];
|
| - UIAlertAction* cancelAction =
|
| - [UIAlertAction actionWithTitle:@"Nope."
|
| - style:UIAlertActionStyleCancel
|
| - handler:^(UIAlertAction* action) {
|
| - self.beforeTranslateActionSheet = nil;
|
| - self.translateManager = nil;
|
| - }];
|
| - [_beforeTranslateActionSheet addAction:cancelAction];
|
| +- (void)translationController:(CWVTranslationController*)controller
|
| + didFinishLanguageDetectionWithResult:(CWVLanguageDetectionResult*)result
|
| + error:(NSError*)error {
|
| + self.beforeTranslateActionSheet = [UIAlertController
|
| + alertControllerWithTitle:nil
|
| + message:@"Translate?"
|
| + preferredStyle:UIAlertControllerStyleActionSheet];
|
| + UIAlertAction* cancelAction =
|
| + [UIAlertAction actionWithTitle:@"Nope."
|
| + style:UIAlertActionStyleCancel
|
| + handler:^(UIAlertAction* action) {
|
| + self.beforeTranslateActionSheet = nil;
|
| + }];
|
| + [_beforeTranslateActionSheet addAction:cancelAction];
|
|
|
| - UIAlertAction* translateAction =
|
| - [UIAlertAction actionWithTitle:@"Yes!"
|
| - style:UIAlertActionStyleDefault
|
| - handler:^(UIAlertAction* action) {
|
| - self.beforeTranslateActionSheet = nil;
|
| - [_translateManager translate];
|
| - self.translateManager = nil;
|
| - }];
|
| - [_beforeTranslateActionSheet addAction:translateAction];
|
| + UIAlertAction* translateAction = [UIAlertAction
|
| + actionWithTitle:@"Yes!"
|
| + style:UIAlertActionStyleDefault
|
| + handler:^(UIAlertAction* action) {
|
| + self.beforeTranslateActionSheet = nil;
|
| + CWVTranslationLanguage* source = result.sourceLanguage;
|
| + CWVTranslationLanguage* target = result.targetLanguage;
|
| + [controller translatePageFromLanguage:source toLanguage:target];
|
| + }];
|
| + [_beforeTranslateActionSheet addAction:translateAction];
|
|
|
| - [[UIApplication sharedApplication].keyWindow.rootViewController
|
| - presentViewController:_beforeTranslateActionSheet
|
| - animated:YES
|
| - completion:nil];
|
| - }
|
| + [[UIApplication sharedApplication].keyWindow.rootViewController
|
| + presentViewController:_beforeTranslateActionSheet
|
| + animated:YES
|
| + completion:nil];
|
| +}
|
| +
|
| +- (void)translationController:(CWVTranslationController*)controller
|
| + didStartTranslationFromLanguage:(CWVTranslationLanguage*)sourceLanguage
|
| + toLanguage:(CWVTranslationLanguage*)targetLanguage {
|
| +}
|
| +
|
| +- (void)translationController:(CWVTranslationController*)controller
|
| + didFinishTranslationFromLanguage:(CWVTranslationLanguage*)sourceLanguage
|
| + toLanguage:(CWVTranslationLanguage*)targetLanguage
|
| + error:(NSError*)error {
|
| }
|
|
|
| @end
|
|
|