Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\MessageSync\MessageSourceChange Class Reference

Class is used to track the changes made when importing messages from the remote sources using importExternalTranslations.php. More...

Public Member Functions

 __construct ( $changes=[])
 
 addChange ( $language, $key, $content)
 Add a change under a message group for a specific language.
 
 addAddition ( $language, $key, $content)
 Add an addition under a message group for a specific language.
 
 addDeletion ( $language, $key, $content)
 Adds a deletion under a message group for a specific language.
 
 addRename ( $language, $addedMessage, $deletedMessage, $similarity=0)
 Adds a rename under a message group for a specific language.
 
 setRenameState ( $language, $msgKey, $state)
 
 getChanges ( $language)
 Fetch changes for a message group under a language.
 
 getDeletions ( $language)
 Fetch deletions for a message group under a language.
 
 getAdditions ( $language)
 Fetch additions for a message group under a language.
 
 findMessage ( $language, $key, $possibleStates=[], &$modificationType=null)
 Finds a message with the given key across different types of modifications.
 
 breakRename ( $languageCode, $msgKey)
 Break renames, and put messages back into their previous state.
 
 getRenames ( $language)
 Fetch renames for a message group under a language.
 
 removeAdditions ( $language, $keysToRemove)
 Remove additions for a language under the group.
 
 removeDeletions ( $language, $keysToRemove)
 Remove deletions for a language under the group.
 
 removeChanges ( $language, $keysToRemove)
 Remove changes for a language under the group.
 
 removeRenames ( $language, $keysToRemove)
 Remove renames for a language under the group.
 
 removeBasedOnType ( $language, $keysToRemove, $type)
 Remove modifications based on the type.
 
 removeChangesForLanguage ( $language)
 Remove all language related changes for a group.
 
 getAllModifications ()
 Return all modifications for the group.
 
 getModificationsForLanguage ( $language)
 Get all for a language under the group.
 
 getLanguages ()
 Get all language keys with modifications under the group.
 
 hasOnly ( $language, $type)
 Determines if the group has only a certain type of change under a language.
 
 isPreviousState ( $languageCode, $key, array $types)
 Checks if the previous state of a renamed message matches a given value.
 
 getMatchedMessage ( $languageCode, $key)
 Get matched rename message for a given key.
 
 getMatchedKey ( $languageCode, $key)
 Get matched rename key for a given key.
 
 getSimilarity ( $languageCode, $key)
 Returns the calculated similarity for a rename.
 
 isEqual ( $languageCode, $key)
 Checks if a given key is equal to matched rename message.
 
 isSimilar ( $languageCode, $key)
 Checks if a given key is similar to matched rename message.
 
 areStringsSimilar ( $similarity)
 Checks if the similarity percent passed passes the min threshold.
 
 areStringsEqual ( $similarity)
 Checks if the similarity percent passed.
 

Static Public Member Functions

static loadModifications ( $changesData)
 Loads the changes, and returns an instance of the class.
 

Public Attributes

const ADDITION = 'addition'
 
const CHANGE = 'change'
 
const DELETION = 'deletion'
 
const RENAME = 'rename'
 
const NONE = 'none'
 

Protected Member Functions

 addModification ( $language, $type, $key, $content)
 
 getModification ( $language, $type)
 
 removeModification ( $language, $type, $keysToRemove=null)
 

Protected Attributes

 $changes = []
 
 $addFunctionMap
 
 $removeFunctionMap
 

Detailed Description

Class is used to track the changes made when importing messages from the remote sources using importExternalTranslations.php.

Also provides an interface to query these changes, and update them.

Since
2019.10

Definition at line 19 of file MessageSourceChange.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::__construct ( $changes = [])
Parameters
array[][][]$changes

Definition at line 46 of file MessageSourceChange.php.

Member Function Documentation

◆ addAddition()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::addAddition ( $language,
$key,
$content )

Add an addition under a message group for a specific language.

Parameters
string$language
string$key
string$content

Definition at line 77 of file MessageSourceChange.php.

◆ addChange()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::addChange ( $language,
$key,
$content )

Add a change under a message group for a specific language.

Parameters
string$language
string$key
string$content

Definition at line 67 of file MessageSourceChange.php.

◆ addDeletion()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::addDeletion ( $language,
$key,
$content )

Adds a deletion under a message group for a specific language.

Parameters
string$language
string$key
string$content

Definition at line 87 of file MessageSourceChange.php.

◆ addModification()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::addModification ( $language,
$type,
$key,
$content )
protected
Parameters
string$language
string$type
string$key
string$content

Definition at line 141 of file MessageSourceChange.php.

◆ addRename()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::addRename ( $language,
$addedMessage,
$deletedMessage,
$similarity = 0 )

Adds a rename under a message group for a specific language.

Parameters
string$language
string[]$addedMessage
string[]$deletedMessage
float$similarity

Definition at line 98 of file MessageSourceChange.php.

◆ areStringsEqual()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::areStringsEqual ( $similarity)

Checks if the similarity percent passed.

Parameters
float$similarity
Returns
bool

Definition at line 547 of file MessageSourceChange.php.

◆ areStringsSimilar()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::areStringsSimilar ( $similarity)

Checks if the similarity percent passed passes the min threshold.

Parameters
float$similarity
Returns
bool

Definition at line 538 of file MessageSourceChange.php.

◆ breakRename()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::breakRename ( $languageCode,
$msgKey )

Break renames, and put messages back into their previous state.

Parameters
string$languageCode
string$msgKey
Returns
string|null previous state of the message

Definition at line 226 of file MessageSourceChange.php.

◆ findMessage()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::findMessage ( $language,
$key,
$possibleStates = [],
& $modificationType = null )

Finds a message with the given key across different types of modifications.

Parameters
string$language
string$key
string[]$possibleStates
string | null&$modificationType
Returns
array|null

Definition at line 183 of file MessageSourceChange.php.

◆ getAdditions()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getAdditions ( $language)

Fetch additions for a message group under a language.

Parameters
string$language
Returns
array[]

Definition at line 171 of file MessageSourceChange.php.

◆ getAllModifications()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getAllModifications ( )

Return all modifications for the group.

Returns
array[][][]

Definition at line 384 of file MessageSourceChange.php.

◆ getChanges()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getChanges ( $language)

Fetch changes for a message group under a language.

Parameters
string$language
Returns
array[]

Definition at line 153 of file MessageSourceChange.php.

◆ getDeletions()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getDeletions ( $language)

Fetch deletions for a message group under a language.

Parameters
string$language
Returns
array[]

Definition at line 162 of file MessageSourceChange.php.

◆ getLanguages()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getLanguages ( )

Get all language keys with modifications under the group.

Returns
string[]

Definition at line 410 of file MessageSourceChange.php.

◆ getMatchedKey()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getMatchedKey ( $languageCode,
$key )

Get matched rename key for a given key.

Parameters
string$languageCode
string$key
Returns
string|null Matched key if found, else null

Definition at line 494 of file MessageSourceChange.php.

◆ getMatchedMessage()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getMatchedMessage ( $languageCode,
$key )

Get matched rename message for a given key.

Parameters
string$languageCode
string$key
Returns
array|null Matched message if found, else null

Definition at line 479 of file MessageSourceChange.php.

◆ getModification()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getModification ( $language,
$type )
protected
Parameters
string$language
string$type
Returns
array[]

Definition at line 289 of file MessageSourceChange.php.

◆ getModificationsForLanguage()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getModificationsForLanguage ( $language)

Get all for a language under the group.

Parameters
string$language
Returns
array[][]

Definition at line 393 of file MessageSourceChange.php.

◆ getRenames()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getRenames ( $language)

Fetch renames for a message group under a language.

Parameters
string$language
Returns
array[]

Definition at line 275 of file MessageSourceChange.php.

◆ getSimilarity()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::getSimilarity ( $languageCode,
$key )

Returns the calculated similarity for a rename.

Parameters
string$languageCode
string$key
Returns
float|null

Definition at line 504 of file MessageSourceChange.php.

◆ hasOnly()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::hasOnly ( $language,
$type )

Determines if the group has only a certain type of change under a language.

Parameters
string$language
string$type
Returns
bool

Definition at line 421 of file MessageSourceChange.php.

◆ isEqual()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::isEqual ( $languageCode,
$key )

Checks if a given key is equal to matched rename message.

Parameters
string$languageCode
string$key
Returns
bool

Definition at line 516 of file MessageSourceChange.php.

◆ isPreviousState()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::isPreviousState ( $languageCode,
$key,
array $types )

Checks if the previous state of a renamed message matches a given value.

Parameters
string$languageCode
string$key
string[]$types
Returns
bool

Definition at line 467 of file MessageSourceChange.php.

◆ isSimilar()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::isSimilar ( $languageCode,
$key )

Checks if a given key is similar to matched rename message.

Parameters
string$languageCode
string$key
Returns
bool

Definition at line 528 of file MessageSourceChange.php.

◆ loadModifications()

static MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::loadModifications ( $changesData)
static

Loads the changes, and returns an instance of the class.

Parameters
array$changesData
Returns
self

Definition at line 402 of file MessageSourceChange.php.

◆ removeAdditions()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeAdditions ( $language,
$keysToRemove )

Remove additions for a language under the group.

Parameters
string$language
array | null$keysToRemove

Definition at line 298 of file MessageSourceChange.php.

◆ removeBasedOnType()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeBasedOnType ( $language,
$keysToRemove,
$type )

Remove modifications based on the type.

Avoids usage of ugly if / switch statement.

Parameters
string$language
array$keysToRemove
string$typeOne of ADDITION, CHANGE, DELETION

Definition at line 336 of file MessageSourceChange.php.

◆ removeChanges()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeChanges ( $language,
$keysToRemove )

Remove changes for a language under the group.

Parameters
string$language
array | null$keysToRemove

Definition at line 316 of file MessageSourceChange.php.

◆ removeChangesForLanguage()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeChangesForLanguage ( $language)

Remove all language related changes for a group.

Parameters
string$language

Definition at line 353 of file MessageSourceChange.php.

◆ removeDeletions()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeDeletions ( $language,
$keysToRemove )

Remove deletions for a language under the group.

Parameters
string$language
array | null$keysToRemove

Definition at line 307 of file MessageSourceChange.php.

◆ removeModification()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeModification ( $language,
$type,
$keysToRemove = null )
protected

Definition at line 357 of file MessageSourceChange.php.

◆ removeRenames()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::removeRenames ( $language,
$keysToRemove )

Remove renames for a language under the group.

Parameters
string$language
array | null$keysToRemove

Definition at line 325 of file MessageSourceChange.php.

◆ setRenameState()

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::setRenameState ( $language,
$msgKey,
$state )

Definition at line 116 of file MessageSourceChange.php.

Member Data Documentation

◆ $addFunctionMap

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::$addFunctionMap
protected

Definition at line 38 of file MessageSourceChange.php.

◆ $changes

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::$changes = []
protected

Definition at line 25 of file MessageSourceChange.php.

◆ $removeFunctionMap

MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::$removeFunctionMap
protected

Definition at line 43 of file MessageSourceChange.php.

◆ ADDITION

const MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::ADDITION = 'addition'

Definition at line 26 of file MessageSourceChange.php.

◆ CHANGE

const MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::CHANGE = 'change'

Definition at line 27 of file MessageSourceChange.php.

◆ DELETION

const MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::DELETION = 'deletion'

Definition at line 28 of file MessageSourceChange.php.

◆ NONE

const MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::NONE = 'none'

Definition at line 30 of file MessageSourceChange.php.

◆ RENAME

const MediaWiki\Extension\Translate\MessageSync\MessageSourceChange::RENAME = 'rename'

Definition at line 29 of file MessageSourceChange.php.


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