TranslationWebService Class Reference

Inheritance diagram for TranslationWebService:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 getSuggestions ($translations, $sourceLanguage, $targetLanguage)
 Do the only supported thing for web services: get a suggestion for translation.
 checkTranslationServiceFailure ()
 Checks whether the service has exceeded failure count.

Static Public Member Functions

static factory ($name, $config)
 Get a webservice handler.

Protected Member Functions

 mapCode ($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.
 doRequest ($text, $from, $to)
 Get the suggestion.
 __construct ($service, $config)
 getSupportedLanguagePairs ()
 wrapUntranslatable ($text)
 Some mangling that tries to keep some parts of the message unmangled by the translation service.
 unwrapUntranslatable ($text)
 Undo the hopyfully untouched mangling done by wrapUntranslatable.
 reportTranslationServiceFailure (Exception $e)
 Increases the failure count for this service.

Protected Attributes

 $service
 $config
 $serviceFailureCount = 5
 How many failures during failure period need to happen to consider the service being temporarily off-line.
 $serviceFailurePeriod = 900
 How long after the last detected failure we clear the status and try again.

Detailed Description

Definition at line 20 of file TranslationWebService.php.


Constructor & Destructor Documentation

TranslationWebService::__construct ( service,
config 
) [protected]

Definition at line 159 of file TranslationWebService.php.


Member Function Documentation

TranslationWebService::checkTranslationServiceFailure (  ) 

Checks whether the service has exceeded failure count.

Returns:
bool

Definition at line 221 of file TranslationWebService.php.

Referenced by getSuggestions(), and RemoteTTMServerWebService::getSuggestions().

TranslationWebService::doPairs (  )  [abstract, 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

Reimplemented in ApertiumWebService, MicrosoftWebService, RemoteTTMServerWebService, and YandexWebService.

Referenced by getSupportedLanguagePairs().

TranslationWebService::doRequest ( text,
from,
to 
) [abstract, protected]

Get the suggestion.

See getSuggestions for the public method.

Parameters:
string $text Text to translate.
string $from Language code of the text, as used by the service.
string $to Language code of the translation, as used by the service.
Returns:
string Translation suggestion.

Reimplemented in ApertiumWebService, MicrosoftWebService, RemoteTTMServerWebService, and YandexWebService.

Referenced by getSuggestions().

static TranslationWebService::factory ( name,
config 
) [static]

Get a webservice handler.

See also:
$wgTranslateTranslationServices
Parameters:
string $name Name of the service.
array $config
Returns:
TranslationWebService|null

Definition at line 31 of file TranslationWebService.php.

Referenced by MicrosoftWebService::doPairs(), YandexWebService::doRequest(), RemoteTTMServerWebService::doRequest(), MicrosoftWebService::doRequest(), ApertiumWebService::doRequest(), TTMServerAid::getData(), and MachineTranslationAid::getData().

TranslationWebService::getSuggestions ( translations,
sourceLanguage,
targetLanguage 
)

Do the only supported thing for web services: get a suggestion for translation.

Prefers source language as input for suggestions.

Parameters:
array $translations List of all translations listed by language code.
string $sourceLanguage Language code as used by MediaWiki.
string $targetLanguage Language code as used by MediaWiki.
Returns:
array[] The returned suggestion arrays contain the following keys:
  • value: the suggestion
  • language: the language of the suggestion (=$targetLanguage)
  • source_text: the text used as input for the web service
  • source_language: the language of the text used as input
  • service: name of the web service

Reimplemented in RemoteTTMServerWebService.

Definition at line 66 of file TranslationWebService.php.

Here is the call graph for this function:

TranslationWebService::getSupportedLanguagePairs (  )  [protected]
See also:
doPairs

Definition at line 167 of file TranslationWebService.php.

Referenced by getSuggestions().

Here is the call graph for this function:

TranslationWebService::mapCode ( code  )  [abstract, protected]

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

Parameters:
string $code MediaWiki language code.
Returns:
string Translation service language code.

Reimplemented in ApertiumWebService, MicrosoftWebService, RemoteTTMServerWebService, and YandexWebService.

Referenced by getSuggestions().

TranslationWebService::reportTranslationServiceFailure ( Exception $  e  )  [protected]

Increases the failure count for this service.

Definition at line 252 of file TranslationWebService.php.

Referenced by getSuggestions(), and RemoteTTMServerWebService::getSuggestions().

TranslationWebService::unwrapUntranslatable ( text  )  [protected]

Undo the hopyfully untouched mangling done by wrapUntranslatable.

Definition at line 196 of file TranslationWebService.php.

Referenced by YandexWebService::doRequest(), MicrosoftWebService::doRequest(), and ApertiumWebService::doRequest().

TranslationWebService::wrapUntranslatable ( 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.

Definition at line 184 of file TranslationWebService.php.

Referenced by YandexWebService::doRequest(), MicrosoftWebService::doRequest(), and ApertiumWebService::doRequest().


Member Data Documentation

TranslationWebService::$config [protected]

Definition at line 157 of file TranslationWebService.php.

Referenced by __construct(), and factory().

TranslationWebService::$service [protected]
TranslationWebService::$serviceFailureCount = 5 [protected]

How many failures during failure period need to happen to consider the service being temporarily off-line.

Definition at line 210 of file TranslationWebService.php.

TranslationWebService::$serviceFailurePeriod = 900 [protected]

How long after the last detected failure we clear the status and try again.

Definition at line 215 of file TranslationWebService.php.


The documentation for this class was generated from the following file:
Generated on Tue Oct 29 00:00:56 2013 for MediaWiki Translate Extension by  doxygen 1.6.3