abstract class BaseTranslationApi

Class BaseTranslationApi

Properties

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

Methods

array
checkRequirements()

Checks if all requirements are set for a successfull translation call

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

No description

string
getContent()

No description

string
getSourceLanguage()

No description

string
getTargetLanguage()

No description

string
getTranslatedContent()

No description

string
getUrl()

No description

bool
hasFeedbackLoop()

No description

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

Send feedback aka improved human translation to the API

void
setBackgroundTranslationToDisabled()

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

setContent(string $content)

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)

Translates content to target language. Possible errors should be added to the error array.

Details

at line 152
protected array checkRequirements()

Checks if all requirements are set for a successfull translation call

Return Value

array

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

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

No description

Parameters

string $apiStatusMessage

Return Value

bool|null

at line 67
string getContent()

No description

Return Value

string

at line 53
string getSourceLanguage()

No description

Return Value

string

at line 81
string getTargetLanguage()

No description

Return Value

string

at line 95
string getTranslatedContent()

No description

Return Value

string

at line 39
string getUrl()

No description

Return Value

string

at line 109
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 125
void sendFeedback(string $text, string $human, string $srcLang, string $tgtLang, string $originalTranslation)

Send feedback aka improved human translation to the API

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

Exceptions

TranslationException

On error

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

at line 74
setContent(string $content)

No description

Parameters

string $content

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 60
setSourceLanguage(string $source_language)

No description

Parameters

string $source_language

at line 88
setTargetLanguage(string $target_language)

No description

Parameters

string $target_language

at line 102
setTranslatedContent(string $translated_content)

No description

Parameters

string $translated_content

at line 46
setUrl(string $url)

No description

Parameters

string $url

at line 178
abstract array translate(null|string $content = null, null|string $target_language = null)

Translates content to target language. Possible errors should be added to the error array.

Parameters

null|string $content
null|string $target_language

Return Value

array

$errors Is an empty Array if no errors.

Exceptions

TranslationException