Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -405,8 +405,6 @@ |
406 | 406 | $boxes[] = $this->getTmBox( $name, $config ); |
407 | 407 | } elseif ( $config['type'] === 'ttmserver' ) { |
408 | 408 | $boxes[] = $this->getTTMServerBox( $name, $config ); |
409 | | - } elseif ( $config['type'] === 'google' ) { |
410 | | - $boxes[] = $this->getGoogleSuggestion( $name, $config ); |
411 | 409 | } elseif ( $config['type'] === 'microsoft' ) { |
412 | 410 | $boxes[] = $this->getMicrosoftSuggestion( $name, $config ); |
413 | 411 | } elseif ( $config['type'] === 'apertium' ) { |
— | — | @@ -429,60 +427,6 @@ |
430 | 428 | } |
431 | 429 | } |
432 | 430 | |
433 | | - protected function getGoogleSuggestion( $serviceName, $config ) { |
434 | | - global $wgMemc; |
435 | | - |
436 | | - $this->mustHaveDefinition(); |
437 | | - self::checkTranslationServiceFailure( $serviceName ); |
438 | | - |
439 | | - $code = $this->handle->getCode(); |
440 | | - $definition = trim( strval( $this->getDefinition() ) ); |
441 | | - $definition = self::wrapUntranslatable( $definition ); |
442 | | - |
443 | | - $memckey = wfMemckey( 'translate-tmsug-badcodes-' . $serviceName ); |
444 | | - $unsupported = $wgMemc->get( $memckey ); |
445 | | - |
446 | | - if ( isset( $unsupported[$code] ) ) { |
447 | | - return null; |
448 | | - } |
449 | | - |
450 | | - /* There is 5000 *character* limit, but encoding needs to be taken into |
451 | | - * account. Not sure if this applies also to post method. */ |
452 | | - if ( strlen( rawurlencode( $definition ) ) > 4900 ) { |
453 | | - return null; |
454 | | - } |
455 | | - |
456 | | - $source = $this->group->getSourceLanguage(); |
457 | | - $options = self::makeGoogleQueryParams( $definition, "$source|$code", $config ); |
458 | | - $json = Http::post( $config['url'], $options ); |
459 | | - $response = FormatJson::decode( $json ); |
460 | | - |
461 | | - if ( $json === false ) { |
462 | | - // Most likely a timeout or other general error |
463 | | - self::reportTranslationServiceFailure( $serviceName ); |
464 | | - } elseif ( !is_object( $response ) ) { |
465 | | - error_log( __METHOD__ . ': Unable to parse reply: ' . strval( $json ) ); |
466 | | - return null; |
467 | | - } |
468 | | - |
469 | | - if ( $response->responseStatus === 200 ) { |
470 | | - $text = Sanitizer::decodeCharReferences( $response->responseData->translatedText ); |
471 | | - $text = self::unwrapUntranslatable( $text ); |
472 | | - $text = $this->suggestionField( $text ); |
473 | | - return Html::rawElement( 'div', null, self::legend( $serviceName ) . $text . self::clear() ); |
474 | | - } elseif ( $response->responseDetails === 'invalid translation language pair' ) { |
475 | | - $unsupported[$code] = true; |
476 | | - $wgMemc->set( $memckey, $unsupported, 60 * 60 * 8 ); |
477 | | - } else { |
478 | | - // Unknown error, assume the worst |
479 | | - wfWarn( __METHOD__ . "($serviceName): " . $response->responseDetails ); |
480 | | - error_log( __METHOD__ . "($serviceName): " . $response->responseDetails ); |
481 | | - self::reportTranslationServiceFailure( $serviceName ); |
482 | | - } |
483 | | - |
484 | | - return null; |
485 | | - } |
486 | | - |
487 | 431 | protected static function makeGoogleQueryParams( $definition, $pair, $config ) { |
488 | 432 | global $wgSitename, $wgVersion, $wgProxyKey, $wgUser; |
489 | 433 | $options = array(); |