class Transperfect extends BaseTranslationApi

Constants

APIURL_ENDPOINT_TRANSLATE

APIURL_ENDPOINT_FEEDBACK

Properties

TranslationController $mod from  BaseTranslationApi
array $ignoreTags from  BaseTranslationApi
protected string $url from  BaseTranslationApi
protected string $source_language from  BaseTranslationApi
protected string $content from  BaseTranslationApi
protected string $target_language from  BaseTranslationApi
protected string $translated_content from  BaseTranslationApi
protected string $key

Methods

array
checkRequirements()

No description

bool|null
getAPIStatus(string $apiStatusMessage = '')

No description

string
getContent()

No description

string
getKey()

No description

string
getSourceLanguage()

No description

string
getTargetLanguage()

No description

string
getTranslatedContent()

No description

array|null
getTranslation()

Queries API and returns result data array

string
getUrl()

Trims the url provided by config value and also removes a trailing slash if present.

bool
hasFeedbackLoop()

No description

void
sendFeedback(string $text, string $human, string $srcLang, string $tgtLang, string $originalTranslation)

No description

Response
sendFormRequest(string $url, array $headers, array $body)

Returns the response from the endpoint. Form post.

void
setBackgroundTranslationToDisabled()

Sets the config var 'translation_enabled' to false to disable automatic translations.

setContent(string $content)

No description

setKey(string $key)

No description

void
setParameters(string $content, string $target_language)

Sets possible content and target language

setSourceLanguage(string $source_language)

No description

setTargetLanguage(string $target_language)

No description

setTranslatedContent(string $translated_content)

No description

setUrl(string $url)

No description

array
translate(null|string $content = NULL, null|string $target_language = NULL)

No description

Details

at line 197
protected array checkRequirements()

No description

Return Value

array

$errors Is an ampty array if there are no errors.

in BaseTranslationApi at line 186
bool|null getAPIStatus(string $apiStatusMessage = '')

No description

Parameters

string $apiStatusMessage

Return Value

bool|null

in BaseTranslationApi at line 67
string getContent()

No description

Return Value

string

at line 19
string getKey()

No description

Return Value

string

in BaseTranslationApi at line 53
string getSourceLanguage()

No description

Return Value

string

in BaseTranslationApi at line 81
string getTargetLanguage()

No description

Return Value

string

in BaseTranslationApi at line 95
string getTranslatedContent()

No description

Return Value

string

at line 155
protected array|null getTranslation()

Queries API and returns result data array

Return Value

array|null

$data The translation result data

Exceptions

TranslationException

at line 37
string getUrl()

Trims the url provided by config value and also removes a trailing slash if present.

Return Value

string

at line 212
bool hasFeedbackLoop()

No description

Return Value

bool

This Api has a feedback loop. It is possible to send inproved translations to an endpoint

at line 219
void sendFeedback(string $text, string $human, string $srcLang, string $tgtLang, string $originalTranslation)

No description

Parameters

string $text

The source text in the source language

string $human

The improved human translation in the target language

string $srcLang

The source language string

string $tgtLang

The target language string

string $originalTranslation

The original received auto translation

Return Value

void

at line 131
protected Response sendFormRequest(string $url, array $headers, array $body)

Returns the response from the endpoint. Form post.

Parameters

string $url

The endpoint url

array $headers

The headers as ['headerName' => 'value']

array $body

The Form values ['source'=>'de', ...]

Return Value

Response

Exceptions

ConnectionErrorException

in BaseTranslationApi at line 215
void setBackgroundTranslationToDisabled()

Sets the config var 'translation_enabled' to false to disable automatic translations.

Is triggered for example by a translation character quota bigger than 98%

Return Value

void

in BaseTranslationApi at line 74
setContent(string $content)

No description

Parameters

string $content

at line 27
setKey(string $key)

No description

Parameters

string $key

in BaseTranslationApi at line 135
protected void setParameters(string $content, string $target_language)

Sets possible content and target language

Parameters

string $content
string $target_language

Return Value

void

at line 45
setSourceLanguage(string $source_language)

No description

Parameters

string $source_language

Exceptions

TranslationException

if source language is unknown

in BaseTranslationApi at line 88
setTargetLanguage(string $target_language)

No description

Parameters

string $target_language

in BaseTranslationApi at line 102
setTranslatedContent(string $translated_content)

No description

Parameters

string $translated_content

in BaseTranslationApi at line 46
setUrl(string $url)

No description

Parameters

string $url

at line 86
array translate(null|string $content = NULL, null|string $target_language = NULL)

No description

Parameters

null|string $content
null|string $target_language

Return Value

array

$errors Is an empty Array if no errors.