Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\WebService\TranslationWebService Class Reference
Inheritance diagram for MediaWiki\Extension\Translate\WebService\TranslationWebService:
MediaWiki\Extension\Translate\WebService\ApertiumWebService MediaWiki\Extension\Translate\WebService\CaighdeanWebService MediaWiki\Extension\Translate\WebService\CxserverWebService MediaWiki\Extension\Translate\WebService\GoogleTranslateWebService MediaWiki\Extension\Translate\WebService\MicrosoftWebService MediaWiki\Extension\Translate\WebService\RemoteTTMServerWebService MediaWiki\Extension\Translate\WebService\YandexWebService MediaWiki\Extension\Translate\WebService\ApertiumCxserverWebService MediaWiki\Extension\Translate\WebService\MintCxserverWebService

Public Member Functions

 getName ()
 Gets the name of this service, for example to display it for the user.
 
 getQueries (string $text, string $sourceLanguage, string $targetLanguage)
 Get queries for this service.
 
 getResultData (TranslationQueryResponse $response)
 Get the web service specific response returned by QueryAggregator.
 
 getType ()
 Returns the type of this web service.
 
 __construct (string $service, array $config)
 
 isSupportedLanguagePair (string $sourceLanguage, string $targetLanguage)
 Test whether given language pair is supported by the service.
 
 setLogger (LoggerInterface $logger)
 
 checkTranslationServiceFailure ()
 Checks whether the service has exceeded failure count.
 

Static Public Member Functions

static factory (string $serviceName, array $config)
 Get a webservice handler.
 

Protected Member Functions

 mapCode (string $code)
 Map a MediaWiki (almost standard) language code to the code used by the translation service.
 
 doPairs ()
 Get the list of supported language pairs for the web service.
 
 getQuery (string $text, string $sourceLanguage, string $targetLanguage)
 Get the query.
 
 parseResponse (TranslationQueryResponse $response)
 Get the response.
 
 getSupportedLanguagePairs ()
 
 wrapUntranslatable (string $text)
 Some mangling that tries to keep some parts of the message unmangled by the translation service.
 
 unwrapUntranslatable (string $text)
 Undo the hopyfully untouched mangling done by wrapUntranslatable.
 
 reportTranslationServiceFailure (string $msg)
 Increases the failure count for this service.
 

Protected Attributes

 $service
 
 $config
 
 $logger
 
 $serviceFailureCount = 5
 
 $serviceFailurePeriod = 900
 

Detailed Description

Definition at line 25 of file TranslationWebService.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\WebService\TranslationWebService::__construct ( string $service,
array $config )

Definition at line 203 of file TranslationWebService.php.

Member Function Documentation

◆ checkTranslationServiceFailure()

MediaWiki\Extension\Translate\WebService\TranslationWebService::checkTranslationServiceFailure ( )

Checks whether the service has exceeded failure count.

Definition at line 284 of file TranslationWebService.php.

◆ doPairs()

MediaWiki\Extension\Translate\WebService\TranslationWebService::doPairs ( )
abstractprotected

Get the list of supported language pairs for the web service.

The codes should be the ones used by the service. Caching is handled by the public getSupportedLanguagePairs.

Returns
array $list[source language][target language] = true
Exceptions
TranslationWebServiceException
TranslationWebServiceConfigurationException

Reimplemented in MediaWiki\Extension\Translate\WebService\ApertiumWebService, MediaWiki\Extension\Translate\WebService\CaighdeanWebService, MediaWiki\Extension\Translate\WebService\CxserverWebService, MediaWiki\Extension\Translate\WebService\GoogleTranslateWebService, MediaWiki\Extension\Translate\WebService\MicrosoftWebService, MediaWiki\Extension\Translate\WebService\RemoteTTMServerWebService, and MediaWiki\Extension\Translate\WebService\YandexWebService.

◆ factory()

static MediaWiki\Extension\Translate\WebService\TranslationWebService::factory ( string $serviceName,
array $config )
static

Get a webservice handler.

See also
$wgTranslateTranslationServices

Definition at line 35 of file TranslationWebService.php.

◆ getName()

MediaWiki\Extension\Translate\WebService\TranslationWebService::getName ( )

Gets the name of this service, for example to display it for the user.

Since
2014.02

Definition at line 98 of file TranslationWebService.php.

◆ getQueries()

MediaWiki\Extension\Translate\WebService\TranslationWebService::getQueries ( string $text,
string $sourceLanguage,
string $targetLanguage )

Get queries for this service.

Queries from multiple services can be collected and run asynchronously with QueryAggregator.

Returns
TranslationQuery[]
Since
2015.12
Exceptions
TranslationWebServiceConfigurationException

Definition at line 109 of file TranslationWebService.php.

◆ getQuery()

MediaWiki\Extension\Translate\WebService\TranslationWebService::getQuery ( string $text,
string $sourceLanguage,
string $targetLanguage )
abstractprotected

Get the query.

See getQueries for the public method.

Parameters
string$textText to translate.
string$sourceLanguageLanguage code of the text, as used by the service.
string$targetLanguageLanguage code of the translation, as used by the service.
Since
2015.02
Exceptions
TranslationWebServiceException
TranslationWebServiceConfigurationException
TranslationWebServiceInvalidInputException

Reimplemented in MediaWiki\Extension\Translate\WebService\ApertiumWebService, MediaWiki\Extension\Translate\WebService\CaighdeanWebService, MediaWiki\Extension\Translate\WebService\CxserverWebService, MediaWiki\Extension\Translate\WebService\GoogleTranslateWebService, MediaWiki\Extension\Translate\WebService\MicrosoftWebService, MediaWiki\Extension\Translate\WebService\RemoteTTMServerWebService, and MediaWiki\Extension\Translate\WebService\YandexWebService.

◆ getResultData()

MediaWiki\Extension\Translate\WebService\TranslationWebService::getResultData ( TranslationQueryResponse $response)

Get the web service specific response returned by QueryAggregator.

Returns
mixed|null Returns null on error.
Since
2015.12

Definition at line 129 of file TranslationWebService.php.

◆ getSupportedLanguagePairs()

MediaWiki\Extension\Translate\WebService\TranslationWebService::getSupportedLanguagePairs ( )
protected
See also
self::doPairs
Exceptions
TranslationWebServiceConfigurationException

Definition at line 225 of file TranslationWebService.php.

◆ getType()

◆ isSupportedLanguagePair()

MediaWiki\Extension\Translate\WebService\TranslationWebService::isSupportedLanguagePair ( string $sourceLanguage,
string $targetLanguage )

Test whether given language pair is supported by the service.

Since
2015.12
Exceptions
TranslationWebServiceConfigurationException

Reimplemented in MediaWiki\Extension\Translate\WebService\GoogleTranslateWebService.

Definition at line 213 of file TranslationWebService.php.

◆ mapCode()

◆ parseResponse()

◆ reportTranslationServiceFailure()

MediaWiki\Extension\Translate\WebService\TranslationWebService::reportTranslationServiceFailure ( string $msg)
protected

Increases the failure count for this service.

Definition at line 319 of file TranslationWebService.php.

◆ setLogger()

MediaWiki\Extension\Translate\WebService\TranslationWebService::setLogger ( LoggerInterface $logger)

Definition at line 268 of file TranslationWebService.php.

◆ unwrapUntranslatable()

MediaWiki\Extension\Translate\WebService\TranslationWebService::unwrapUntranslatable ( string $text)
protected

Undo the hopyfully untouched mangling done by wrapUntranslatable.

Reimplemented in MediaWiki\Extension\Translate\WebService\MicrosoftWebService.

Definition at line 260 of file TranslationWebService.php.

◆ wrapUntranslatable()

MediaWiki\Extension\Translate\WebService\TranslationWebService::wrapUntranslatable ( string $text)
protected

Some mangling that tries to keep some parts of the message unmangled by the translation service.

Most of them support either class=notranslate or translate=no.

Reimplemented in MediaWiki\Extension\Translate\WebService\MicrosoftWebService, and MediaWiki\Extension\Translate\WebService\MintCxserverWebService.

Definition at line 252 of file TranslationWebService.php.

Member Data Documentation

◆ $config

MediaWiki\Extension\Translate\WebService\TranslationWebService::$config
protected

Definition at line 199 of file TranslationWebService.php.

◆ $logger

MediaWiki\Extension\Translate\WebService\TranslationWebService::$logger
protected

Definition at line 201 of file TranslationWebService.php.

◆ $service

MediaWiki\Extension\Translate\WebService\TranslationWebService::$service
protected

Definition at line 197 of file TranslationWebService.php.

◆ $serviceFailureCount

MediaWiki\Extension\Translate\WebService\TranslationWebService::$serviceFailureCount = 5
protected

Definition at line 276 of file TranslationWebService.php.

◆ $serviceFailurePeriod

MediaWiki\Extension\Translate\WebService\TranslationWebService::$serviceFailurePeriod = 900
protected

Definition at line 281 of file TranslationWebService.php.


The documentation for this class was generated from the following file: