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

Public Member Functions

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

Public Attributes

const ALL_LANGUAGES = 'all languages'
 Process all languages supported by the message group.
 

Protected Member Functions

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

Protected Attributes

 $stringComparator
 

Detailed Description

Definition at line 14 of file ExternalMessageSourceStateComparator.php.

Constructor & Destructor Documentation

◆ __construct()

ExternalMessageSourceStateComparator::__construct ( StringComparator $stringComparator)
Parameters
StringComparator$stringComparator

Definition at line 22 of file ExternalMessageSourceStateComparator.php.

Member Function Documentation

◆ addMessageUpdateChanges()

ExternalMessageSourceStateComparator::addMessageUpdateChanges ( FileBasedMessageGroup $group,
$language,
MessageSourceChange $changes,
$reason,
$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.

Parameters
FileBasedMessageGroup$group
string$language
MessageSourceChange$changes
int$reason
MessageGroupCache$cache
Exceptions
RuntimeException

Definition at line 123 of file ExternalMessageSourceStateComparator.php.

◆ processGroup()

ExternalMessageSourceStateComparator::processGroup ( FileBasedMessageGroup $group,
$languages )

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)
Parameters
FileBasedMessageGroup$group
array | string$languages
Exceptions
InvalidArgumentException
Returns
MessageSourceChange

Definition at line 49 of file ExternalMessageSourceStateComparator.php.

◆ processLanguage()

ExternalMessageSourceStateComparator::processLanguage ( FileBasedMessageGroup $group,
$language,
MessageSourceChange $changes )
protected

Definition at line 85 of file ExternalMessageSourceStateComparator.php.

Member Data Documentation

◆ $stringComparator

ExternalMessageSourceStateComparator::$stringComparator
protected

Definition at line 19 of file ExternalMessageSourceStateComparator.php.

◆ ALL_LANGUAGES

const ExternalMessageSourceStateComparator::ALL_LANGUAGES = 'all languages'

Process all languages supported by the message group.

Definition at line 16 of file ExternalMessageSourceStateComparator.php.


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