Translate extension for MediaWiki
Loading...
Searching...
No Matches
NumericalParameterInsertablesSuggester.php
1
<?php
2
declare( strict_types = 1 );
3
4
namespace
MediaWiki\Extension\Translate\TranslatorInterface\Insertable;
5
12
class
NumericalParameterInsertablesSuggester
implements
InsertablesSuggester
{
13
public
function
getInsertables
(
string
$text ): array {
14
$insertables = [];
15
16
// $1, $2, $3 etc.
17
$matches = [];
18
preg_match_all(
19
'/\$\d+/'
,
20
$text,
21
$matches,
22
PREG_SET_ORDER
23
);
24
$new = array_map(
static
function
( $match ) {
25
return
new
Insertable
( $match[0], $match[0] );
26
}, $matches );
27
$insertables = array_merge( $insertables, $new );
28
29
return
$insertables;
30
}
31
}
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\Insertable
Insertable is a string that usually does not need translation and is difficult to type manually.
Definition
Insertable.php:13
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\NumericalParameterInsertablesSuggester
Insertables suggester for numerical parameters such as $1, $2, $3.
Definition
NumericalParameterInsertablesSuggester.php:12
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\NumericalParameterInsertablesSuggester\getInsertables
getInsertables(string $text)
Returns the insertables in the message text.
Definition
NumericalParameterInsertablesSuggester.php:13
MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertablesSuggester
Interface for InsertablesSuggesters.
Definition
InsertablesSuggester.php:13
src
TranslatorInterface
Insertable
NumericalParameterInsertablesSuggester.php
Generated by
1.10.0