Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\WebService\CxserverWebService Class Reference

Used for interacting with translation services supported by Cxserver. More...

Inheritance diagram for MediaWiki\Extension\Translate\WebService\CxserverWebService:
MediaWiki\Extension\Translate\WebService\TranslationWebService MediaWiki\Extension\Translate\WebService\ApertiumCxserverWebService MediaWiki\Extension\Translate\WebService\MintCxserverWebService

Public Member Functions

 __construct (HttpRequestFactory $httpRequestFactory, string $service, array $config)
 
 getType ()
 Returns the type of this web service.
 
- Public Member Functions inherited from MediaWiki\Extension\Translate\WebService\TranslationWebService
 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.
 
 __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.
 

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.
 
 handlePairsForService (array $response)
 
 getServiceName ()
 
 handleServiceResponse (array $responseBody)
 
- Protected Member Functions inherited from MediaWiki\Extension\Translate\WebService\TranslationWebService
 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Extension\Translate\WebService\TranslationWebService
static factory (string $serviceName, array $config)
 Get a webservice handler.
 
- Protected Attributes inherited from MediaWiki\Extension\Translate\WebService\TranslationWebService
 $service
 
 $config
 
 $logger
 
 $serviceFailureCount = 5
 
 $serviceFailurePeriod = 900
 

Detailed Description

Used for interacting with translation services supported by Cxserver.

Author
Abijeet Patro @license GPL-2.0-or-later
Since
2023.06

Definition at line 16 of file CxserverWebService.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\WebService\CxserverWebService::__construct ( HttpRequestFactory $httpRequestFactory,
string $service,
array $config )

Definition at line 19 of file CxserverWebService.php.

Member Function Documentation

◆ doPairs()

MediaWiki\Extension\Translate\WebService\CxserverWebService::doPairs ( )
protected

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 from MediaWiki\Extension\Translate\WebService\TranslationWebService.

Definition at line 39 of file CxserverWebService.php.

◆ getQuery()

MediaWiki\Extension\Translate\WebService\CxserverWebService::getQuery ( string $text,
string $sourceLanguage,
string $targetLanguage )
protected

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 from MediaWiki\Extension\Translate\WebService\TranslationWebService.

Definition at line 54 of file CxserverWebService.php.

◆ getType()

MediaWiki\Extension\Translate\WebService\CxserverWebService::getType ( )

Returns the type of this web service.

See also
\MediaWiki\Extension\Translate\TranslatorInterface\Aid\TranslationAid::getTypes

Reimplemented from MediaWiki\Extension\Translate\WebService\TranslationWebService.

Definition at line 31 of file CxserverWebService.php.

◆ mapCode()

MediaWiki\Extension\Translate\WebService\CxserverWebService::mapCode ( string $code)
protected

Map a MediaWiki (almost standard) language code to the code used by the translation service.

Reimplemented from MediaWiki\Extension\Translate\WebService\TranslationWebService.

Definition at line 35 of file CxserverWebService.php.

◆ parseResponse()

MediaWiki\Extension\Translate\WebService\CxserverWebService::parseResponse ( TranslationQueryResponse $response)
protected

Get the response.

See getResultData for the public method.

Since
2015.02
Exceptions
TranslationWebServiceException

Reimplemented from MediaWiki\Extension\Translate\WebService\TranslationWebService.

Definition at line 64 of file CxserverWebService.php.


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