Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
TranslatablePageInsertablesSuggester.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\PageTranslation;
5
8
22 public const NAME_PATTERN = '\$[\pL\pN_$-]+';
23
24 public function getInsertables( string $text ): array {
25 $insertables = parent::getInsertables( $text );
26
27 $matches = [];
28 $pattern = '/' . self::NAME_PATTERN . '/u';
29 preg_match_all( $pattern, $text, $matches, PREG_SET_ORDER );
30
31 $new = array_map( static function ( $match ) {
32 // Numerical ones are already handled by parent
33 if ( ctype_digit( substr( $match[0], 1 ) ) ) {
34 return null;
35 }
36
37 return new Insertable( $match[0], $match[0] );
38 }, $matches );
39
40 $new = array_filter( $new );
41 return array_merge( $insertables, $new );
42 }
43}
Insertable is a string that usually does not need translation and is difficult to type manually.