https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112690
Revision: 112690
Author: nikerabbit
Date: 2012-02-29 14:42:29 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
Google no more
Modified Paths:
--------------
trunk/extensions/Translate/utils/TranslationHelpers.php
Modified: trunk/extensions/Translate/utils/TranslationHelpers.php
===================================================================
--- trunk/extensions/Translate/utils/TranslationHelpers.php 2012-02-29
14:35:29 UTC (rev 112689)
+++ trunk/extensions/Translate/utils/TranslationHelpers.php 2012-02-29
14:42:29 UTC (rev 112690)
@@ -405,8 +405,6 @@
$boxes[] = $this->getTmBox( $name, $config );
} elseif ( $config['type'] === 'ttmserver' ) {
$boxes[] = $this->getTTMServerBox( $name,
$config );
- } elseif ( $config['type'] === 'google' ) {
- $boxes[] = $this->getGoogleSuggestion( $name,
$config );
} elseif ( $config['type'] === 'microsoft' ) {
$boxes[] = $this->getMicrosoftSuggestion(
$name, $config );
} elseif ( $config['type'] === 'apertium' ) {
@@ -429,60 +427,6 @@
}
}
- protected function getGoogleSuggestion( $serviceName, $config ) {
- global $wgMemc;
-
- $this->mustHaveDefinition();
- self::checkTranslationServiceFailure( $serviceName );
-
- $code = $this->handle->getCode();
- $definition = trim( strval( $this->getDefinition() ) );
- $definition = self::wrapUntranslatable( $definition );
-
- $memckey = wfMemckey( 'translate-tmsug-badcodes-' .
$serviceName );
- $unsupported = $wgMemc->get( $memckey );
-
- if ( isset( $unsupported[$code] ) ) {
- return null;
- }
-
- /* There is 5000 *character* limit, but encoding needs to be
taken into
- * account. Not sure if this applies also to post method. */
- if ( strlen( rawurlencode( $definition ) ) > 4900 ) {
- return null;
- }
-
- $source = $this->group->getSourceLanguage();
- $options = self::makeGoogleQueryParams( $definition,
"$source|$code", $config );
- $json = Http::post( $config['url'], $options );
- $response = FormatJson::decode( $json );
-
- if ( $json === false ) {
- // Most likely a timeout or other general error
- self::reportTranslationServiceFailure( $serviceName );
- } elseif ( !is_object( $response ) ) {
- error_log( __METHOD__ . ': Unable to parse reply: ' .
strval( $json ) );
- return null;
- }
-
- if ( $response->responseStatus === 200 ) {
- $text = Sanitizer::decodeCharReferences(
$response->responseData->translatedText );
- $text = self::unwrapUntranslatable( $text );
- $text = $this->suggestionField( $text );
- return Html::rawElement( 'div', null, self::legend(
$serviceName ) . $text . self::clear() );
- } elseif ( $response->responseDetails === 'invalid translation
language pair' ) {
- $unsupported[$code] = true;
- $wgMemc->set( $memckey, $unsupported, 60 * 60 * 8 );
- } else {
- // Unknown error, assume the worst
- wfWarn( __METHOD__ . "($serviceName): " .
$response->responseDetails );
- error_log( __METHOD__ . "($serviceName): " .
$response->responseDetails );
- self::reportTranslationServiceFailure( $serviceName );
- }
-
- return null;
- }
-
protected static function makeGoogleQueryParams( $definition, $pair,
$config ) {
global $wgSitename, $wgVersion, $wgProxyKey, $wgUser;
$options = array();
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs