Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester Class Reference

Regex InsertablesSuggester implementation that can be extended or used for insertables in message groups. More...

Inheritance diagram for MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester:
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertablesSuggester MediaWiki\Extension\Translate\Validation\Validators\InsertableRegexValidator 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.
 
 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
 

Detailed Description

Regex InsertablesSuggester implementation that can be extended or used for insertables in message groups.

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

Definition at line 15 of file RegexInsertablesSuggester.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::__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 in MediaWiki\Extension\Translate\Validation\Validators\InsertableRegexValidator.

Definition at line 70 of file RegexInsertablesSuggester.php.

Member Function Documentation

◆ getInsertables()

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::getInsertables ( string $text)

Returns the insertables in the message text.

Returns
Insertable[]

Implements MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertablesSuggester.

Definition at line 94 of file RegexInsertablesSuggester.php.

◆ mapInsertables()

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::mapInsertables ( array $match)
protected

Definition at line 101 of file RegexInsertablesSuggester.php.

Member Data Documentation

◆ $display

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::$display = null
protected

Definition at line 26 of file RegexInsertablesSuggester.php.

◆ $post

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::$post = null
protected

Definition at line 36 of file RegexInsertablesSuggester.php.

◆ $pre

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::$pre = null
protected

Definition at line 31 of file RegexInsertablesSuggester.php.

◆ $regex

MediaWiki\Extension\Translate\TranslatorInterface\Insertable\RegexInsertablesSuggester::$regex = null
protected

Definition at line 20 of file RegexInsertablesSuggester.php.


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