Regex InsertablesSuggester implementation that can be extended or used for insertables in message groups. More...
Public Member Functions | |
__construct ( $params) | |
Constructor function. | |
getInsertables (string $text) | |
Returns the insertables in the message text. | |
Protected Member Functions | |
mapInsertables (array $match) | |
Protected Attributes | |
$regex = null | |
$display = null | |
$pre = null | |
$post = null | |
Regex InsertablesSuggester implementation that can be extended or used for insertables in message groups.
Definition at line 15 of file RegexInsertablesSuggester.php.
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::__construct | ( | $params | ) |
Constructor function.
array | string | $params | If 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:
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 in MediaWiki\Extension\Translate\Validation\Validators\InsertableRegexValidator.
Definition at line 70 of file RegexInsertablesSuggester.php.
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::getInsertables | ( | string | $text | ) |
Returns the insertables in the message text.
Implements MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertablesSuggester.
Definition at line 94 of file RegexInsertablesSuggester.php.
|
protected |
Definition at line 101 of file RegexInsertablesSuggester.php.
|
protected |
Definition at line 26 of file RegexInsertablesSuggester.php.
|
protected |
Definition at line 36 of file RegexInsertablesSuggester.php.
|
protected |
Definition at line 31 of file RegexInsertablesSuggester.php.
|
protected |
Definition at line 20 of file RegexInsertablesSuggester.php.