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

A generic regex validator and insertable that can be reused by other classes. More...

Inheritance diagram for MediaWiki\Extension\Translate\Validation\Validators\InsertableRegexValidator:
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester MediaWiki\Extension\Translate\Validation\MessageValidator MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertablesSuggester MediaWiki\Extension\Translate\Validation\Validators\InsertableRubyVariableValidator MediaWiki\Extension\Translate\Validation\Validators\IosVariableValidator MediaWiki\Extension\Translate\Validation\Validators\MediaWikiParameterValidator MediaWiki\Extension\Translate\Validation\Validators\NumericalParameterValidator MediaWiki\Extension\Translate\Validation\Validators\PrintfValidator MediaWiki\Extension\Translate\Validation\Validators\PythonInterpolationValidator

Public Member Functions

 __construct ( $params)
 Constructor function.
 
 getIssues (Message $message, string $targetLanguage)
 
- Public Member Functions inherited from MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester
 getInsertables (string $text)
 Returns the insertables in the message text.
 

Additional Inherited Members

- Protected Member Functions inherited from MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester
 mapInsertables (array $match)
 
- Protected Attributes inherited from MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester
 $regex = null
 
 $display = null
 
 $pre = null
 
 $post = null
 

Detailed Description

A generic regex validator and insertable that can be reused by other classes.

Author
Abijeet Patro @license GPL-2.0-or-later
Since
2019.06

Definition at line 19 of file InsertableRegexValidator.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\Validation\Validators\InsertableRegexValidator::__construct ( $params)

Constructor function.

Parameters
array | string$paramsIf params is specified as a string, it is used as the regex. Eg: "/\$[a-z0-9]+/". In this case display is the first value from the regex match. pre is also the first value from the regex match, post is left empty.

If params is specified as a collection / array, see below for further details.

Example:

params:
regex: "/(?<pre>\[)[^]]+(?<post>\]\‍([^)]+\‍))/"
display: "$pre $post"
pre: "$pre"
post: "$post"

Details:

$params = [ 'regex' => (string, required) The regex to be used for insertable. Must use named captures. When specifying named captures, do not use the $ symbol in the name. In the above example, two named captures are used - pre and post 'display' => (string) Mandatory value. The display value for the insertable. Named captures prefixed with $ are used here. 'pre' => (string) The pre value for the insertable. Named captures prefixed with $ are used here. If not specified, is set to the display value. 'post' => (string) The post value for the insertable. Named captures prefixed with $ are used here. If not specified, defaults to an empty string. ]

Reimplemented from MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester.

Definition at line 23 of file InsertableRegexValidator.php.

Member Function Documentation

◆ getIssues()

MediaWiki\Extension\Translate\Validation\Validators\InsertableRegexValidator::getIssues ( Message $message,
string $targetLanguage )

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