Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\TtmServer\FakeTtmServer Class Reference

NO-OP version of TtmServer when it is disabled. More...

Inheritance diagram for MediaWiki\Extension\Translate\TtmServer\FakeTtmServer:
MediaWiki\Extension\Translate\TtmServer\TtmServer MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer MediaWiki\Extension\Translate\TtmServer\WritableTtmServer

Public Member Functions

 query (string $sourceLanguage, string $targetLanguage, string $text)
 Fetches all relevant suggestions for given text.
 
 isLocalSuggestion (array $suggestion)
 Determines if the suggestion returned by this TtmServer comes from this wiki or any other wiki.
 
 expandLocation (array $suggestion)
 Given suggestion returned by this TtmServer, constructs fully qualified URL to the location of the translation.
 
 update (MessageHandle $handle, ?string $targetText)
 Shovels the new translation into translation memory.
 
 beginBootstrap ()
 Called when starting to fill the translation memory.
 
 beginBatch ()
 Called before every batch (MessageGroup).
 
 batchInsertDefinitions (array $batch)
 Called multiple times per batch if necessary.
 
 batchInsertTranslations (array $batch)
 Called multiple times per batch if necessary.
 
 endBatch ()
 Called after every batch (MessageGroup).
 
 endBootstrap ()
 Do any cleanup, optimizing etc.
 
 setDoReIndex ()
 Instruct the service to fully wipe the index and start from scratch.
 
- Public Member Functions inherited from MediaWiki\Extension\Translate\TtmServer\TtmServer
 __construct (array $config)
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Extension\Translate\TtmServer\TtmServer
static sortSuggestions (array $suggestions)
 
static onDelete (WikiPage $wikipage)
 Hook: ArticleDeleteComplete.
 
static onChange (MessageHandle $handle)
 Called from TranslateEditAddons::onSave.
 
static onGroupChange (MessageHandle $handle, array $old)
 
- Protected Attributes inherited from MediaWiki\Extension\Translate\TtmServer\TtmServer
array $config
 

Detailed Description

NO-OP version of TtmServer when it is disabled.

Keeps other code simpler when they can just do TTMServer::primary()->update( ... );

Author
Niklas Laxström

Definition at line 18 of file FakeTtmServer.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::__construct ( )

Definition at line 19 of file FakeTtmServer.php.

Member Function Documentation

◆ batchInsertDefinitions()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::batchInsertDefinitions ( array $batch)

Called multiple times per batch if necessary.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 45 of file FakeTtmServer.php.

◆ batchInsertTranslations()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::batchInsertTranslations ( array $batch)

Called multiple times per batch if necessary.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 48 of file FakeTtmServer.php.

◆ beginBatch()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::beginBatch ( )

Called before every batch (MessageGroup).

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 42 of file FakeTtmServer.php.

◆ beginBootstrap()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::beginBootstrap ( )

Called when starting to fill the translation memory.

Set up necessary variables and remove old content from the server.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 39 of file FakeTtmServer.php.

◆ endBatch()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::endBatch ( )

Called after every batch (MessageGroup).

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 51 of file FakeTtmServer.php.

◆ endBootstrap()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::endBootstrap ( )

Do any cleanup, optimizing etc.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 54 of file FakeTtmServer.php.

◆ expandLocation()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::expandLocation ( array $suggestion)

Given suggestion returned by this TtmServer, constructs fully qualified URL to the location of the translation.

Returns
string URL

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 31 of file FakeTtmServer.php.

◆ isLocalSuggestion()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::isLocalSuggestion ( array $suggestion)

Determines if the suggestion returned by this TtmServer comes from this wiki or any other wiki.

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 27 of file FakeTtmServer.php.

◆ query()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::query ( string $sourceLanguage,
string $targetLanguage,
string $text )

Fetches all relevant suggestions for given text.

Parameters
string$sourceLanguagelanguage code for the provide text
string$targetLanguagelanguage code for the suggestions
string$textthe text for which to search suggestions
Returns
array List: unordered suggestions, which each has fields:
  • source: String: the original text of the suggestion
  • target: String: the suggestion
  • context: String: title of the page where the suggestion comes from
  • quality: Float: the quality of suggestion, 1 is perfect match

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 23 of file FakeTtmServer.php.

◆ setDoReIndex()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::setDoReIndex ( )

Instruct the service to fully wipe the index and start from scratch.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 57 of file FakeTtmServer.php.

◆ update()

MediaWiki\Extension\Translate\TtmServer\FakeTtmServer::update ( MessageHandle $handle,
?string $targetText )

Shovels the new translation into translation memory.

Use this for single updates (=after message edit). If no text is provided, entry will be removed from the translation memory.

Parameters
MessageHandle$handle
string | null$targetTextUse null to only delete.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 35 of file FakeTtmServer.php.


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