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. |
Definition at line 20 of file TranslationWebService.php.
TranslationWebService::__construct | ( | $ | service, | |
$ | config | |||
) | [protected] |
Definition at line 159 of file TranslationWebService.php.
TranslationWebService::checkTranslationServiceFailure | ( | ) |
Checks whether the service has exceeded failure count.
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.
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.
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. |
Reimplemented in ApertiumWebService, MicrosoftWebService, RemoteTTMServerWebService, and YandexWebService.
Referenced by getSuggestions().
static TranslationWebService::factory | ( | $ | name, | |
$ | config | |||
) | [static] |
Get a webservice handler.
string | $name Name of the service. | |
array | $config |
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.
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. |
Reimplemented in RemoteTTMServerWebService.
Definition at line 66 of file TranslationWebService.php.
TranslationWebService::getSupportedLanguagePairs | ( | ) | [protected] |
Definition at line 167 of file TranslationWebService.php.
Referenced by getSuggestions().
TranslationWebService::mapCode | ( | $ | code | ) | [abstract, protected] |
Map a MediaWiki (almost standard) language code to the code used by the translation service.
string | $code MediaWiki 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().
TranslationWebService::$config [protected] |
Definition at line 157 of file TranslationWebService.php.
Referenced by __construct(), and factory().
TranslationWebService::$service [protected] |
Definition at line 152 of file TranslationWebService.php.
Referenced by __construct(), checkTranslationServiceFailure(), YandexWebService::doRequest(), ApertiumWebService::doRequest(), and reportTranslationServiceFailure().
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.