Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\Synchronization\ExternalMessageSourceStateComparator Class Reference

Finds external changes for file based message groups. More...

Public Member Functions

 __construct (StringComparator $stringComparator, RevisionLookup $revisionLookup, PageStore $pageStore)
 
 processGroup (FileBasedMessageGroup $group)
 Finds modifications in external sources compared to wiki state.
 

Protected Member Functions

 addMessageUpdateChanges (FileBasedMessageGroup $group, string $language, MessageSourceChange $changes, int $reason, MessageGroupCache $cache)
 This is the detective novel.
 

Detailed Description

Finds external changes for file based message groups.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 26 of file ExternalMessageSourceStateComparator.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\Synchronization\ExternalMessageSourceStateComparator::__construct ( StringComparator $stringComparator,
RevisionLookup $revisionLookup,
PageStore $pageStore )

Definition at line 31 of file ExternalMessageSourceStateComparator.php.

Member Function Documentation

◆ addMessageUpdateChanges()

MediaWiki\Extension\Translate\Synchronization\ExternalMessageSourceStateComparator::addMessageUpdateChanges ( FileBasedMessageGroup $group,
string $language,
MessageSourceChange $changes,
int $reason,
MessageGroupCache $cache )
protected

This is the detective novel.

We have three sources of information:

  • current message state in the file
  • current message state in the wiki
  • cached message state since cache was last build (usually after export from wiki)

Now we must try to guess what in earth has driven the file state and wiki state out of sync. Then we must compile list of events that would bring those to sync. Types of events are addition, deletion, (content) change and key renames. After that the list of events are stored for later processing of a translation administrator, who can decide what actions to take on those events to bring the state more or less in sync.

Exceptions
RuntimeException

Definition at line 112 of file ExternalMessageSourceStateComparator.php.

◆ processGroup()

MediaWiki\Extension\Translate\Synchronization\ExternalMessageSourceStateComparator::processGroup ( FileBasedMessageGroup $group)

Finds modifications in external sources compared to wiki state.

The MessageSourceChange object returned stores the following about each modification,

  • First level of classification is the language code
  • Second level of classification is the type of modification,
    • addition (new message in the file)
    • deletion (message in wiki not present in the file)
    • change (difference in content)
    • rename (message key is modified)
  • Third level is a list of modifications
  • For each modification, the following is saved,
    • key (the message key)
    • content (the message content in external source, null for deletions)
    • matched_to (present in case of renames, key of the matched message)
    • similarity (present in case of renames, similarity % with the matched message)
    • previous_state (present in case of renames, state of the message before rename)

Definition at line 59 of file ExternalMessageSourceStateComparator.php.


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