Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\Validation\ValidationRunner Class Reference

Message validator is used to run validators to find common mistakes so that translators can fix them quickly. More...

Public Member Functions

 __construct (string $groupId)
 
 setValidators (array $validatorConfigs)
 Set the validators for this group.
 
 addValidator (array $validatorConfig)
 Add a validator for this group.
 
 getValidators ()
 Return the currently set validators for this group.
 
 getInsertableValidators ()
 Return currently set validators that are insertable.
 
 validateMessage (TMessage $message, string $code, bool $ignoreWarnings=false)
 Validate a translation of a message.
 
 quickValidate (TMessage $message, string $code, bool $ignoreWarnings=false)
 Validate a message, and return as soon as any validation fails.
 

Static Public Member Functions

static reloadIgnorePatterns ()
 

Protected Member Functions

 doesKeyMatch (string $key, array $keyMatches)
 Check if key matches validator's key patterns.
 

Static Protected Member Functions

static foldValue (string $value)
 Normalise validator keys.
 

Protected Attributes

 $validators = []
 
 $groupId
 

Detailed Description

Message validator is used to run validators to find common mistakes so that translators can fix them quickly.

This is an improvement over the old Message Checker framework because it allows maintainers to enforce a validation so that translations that do not pass validation are not saved.

To create your own validator, implement the MessageValidator interface.

There are two types of notices - error and warning.

https://www.mediawiki.org/wiki/Help:Extension:Translate/Validators 2019.06

Definition at line 39 of file ValidationRunner.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\Validation\ValidationRunner::__construct ( string $groupId)

Definition at line 47 of file ValidationRunner.php.

Member Function Documentation

◆ addValidator()

MediaWiki\Extension\Translate\Validation\ValidationRunner::addValidator ( array $validatorConfig)

Add a validator for this group.

Definition at line 77 of file ValidationRunner.php.

◆ doesKeyMatch()

MediaWiki\Extension\Translate\Validation\ValidationRunner::doesKeyMatch ( string $key,
array $keyMatches )
protected

Check if key matches validator's key patterns.

Only relevant if the 'include' or 'exclude' option is specified in the validator.

Parameters
string$key
string[]$keyMatches
Returns
bool True if the key matches one of the matchers, false otherwise.

Definition at line 304 of file ValidationRunner.php.

◆ foldValue()

static MediaWiki\Extension\Translate\Validation\ValidationRunner::foldValue ( string $value)
staticprotected

Normalise validator keys.

Definition at line 57 of file ValidationRunner.php.

◆ getInsertableValidators()

MediaWiki\Extension\Translate\Validation\ValidationRunner::getInsertableValidators ( )

Return currently set validators that are insertable.

Returns
MessageValidator[] List of insertable validators

Definition at line 134 of file ValidationRunner.php.

◆ getValidators()

MediaWiki\Extension\Translate\Validation\ValidationRunner::getValidators ( )

Return the currently set validators for this group.

Returns
MessageValidator[] List of validators

Definition at line 119 of file ValidationRunner.php.

◆ quickValidate()

MediaWiki\Extension\Translate\Validation\ValidationRunner::quickValidate ( TMessage $message,
string $code,
bool $ignoreWarnings = false )

Validate a message, and return as soon as any validation fails.

Definition at line 176 of file ValidationRunner.php.

◆ reloadIgnorePatterns()

static MediaWiki\Extension\Translate\Validation\ValidationRunner::reloadIgnorePatterns ( )
static

Definition at line 206 of file ValidationRunner.php.

◆ setValidators()

MediaWiki\Extension\Translate\Validation\ValidationRunner::setValidators ( array $validatorConfigs)

Set the validators for this group.

Removes the existing validators.

Parameters
array$validatorConfigsList of Validator configurations
See also
addValidator()

Definition at line 69 of file ValidationRunner.php.

◆ validateMessage()

MediaWiki\Extension\Translate\Validation\ValidationRunner::validateMessage ( TMessage $message,
string $code,
bool $ignoreWarnings = false )

Validate a translation of a message.

Returns a ValidationResult that contains methods to print the issues.

Definition at line 150 of file ValidationRunner.php.

Member Data Documentation

◆ $groupId

MediaWiki\Extension\Translate\Validation\ValidationRunner::$groupId
protected

Definition at line 43 of file ValidationRunner.php.

◆ $validators

MediaWiki\Extension\Translate\Validation\ValidationRunner::$validators = []
protected

Definition at line 41 of file ValidationRunner.php.


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