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 | |
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.
MediaWiki\Extension\Translate\Validation\ValidationRunner::__construct | ( | string | $groupId | ) |
Definition at line 47 of file ValidationRunner.php.
MediaWiki\Extension\Translate\Validation\ValidationRunner::addValidator | ( | array | $validatorConfig | ) |
Add a validator for this group.
Definition at line 77 of file ValidationRunner.php.
|
protected |
Check if key matches validator's key patterns.
Only relevant if the 'include' or 'exclude' option is specified in the validator.
string | $key | |
string[] | $keyMatches |
Definition at line 304 of file ValidationRunner.php.
|
staticprotected |
Normalise validator keys.
Definition at line 57 of file ValidationRunner.php.
MediaWiki\Extension\Translate\Validation\ValidationRunner::getInsertableValidators | ( | ) |
Return currently set validators that are insertable.
Definition at line 134 of file ValidationRunner.php.
MediaWiki\Extension\Translate\Validation\ValidationRunner::getValidators | ( | ) |
Return the currently set validators for this group.
Definition at line 119 of file ValidationRunner.php.
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.
|
static |
Definition at line 206 of file ValidationRunner.php.
MediaWiki\Extension\Translate\Validation\ValidationRunner::setValidators | ( | array | $validatorConfigs | ) |
Set the validators for this group.
Removes the existing validators.
array | $validatorConfigs | List of Validator configurations |
Definition at line 69 of file ValidationRunner.php.
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.
|
protected |
Definition at line 43 of file ValidationRunner.php.
|
protected |
Definition at line 41 of file ValidationRunner.php.