Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4056741
MediaWikiInsertablesSuggester.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
MediaWikiInsertablesSuggester.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\TranslatorInterface\Insertable
;
/**
* InsertablesSuggester implementation for MediaWiki message translations.
* @author Niklas Laxström
* @license GPL-2.0-or-later
* @since 2020.12
*/
class
MediaWikiInsertablesSuggester
implements
InsertablesSuggester
{
public
function
getInsertables
(
string
$text
):
array
{
$insertables
=
[];
$matches
=
[];
// MediaWiki apihelp messages often have parameters like $1user, which should
// be unchanged in translation.
preg_match_all
(
'/
\$
(1[a-z]+|[0-9]+)/'
,
$text
,
$matches
,
PREG_SET_ORDER
);
$new
=
array_map
(
static
function
(
$match
)
{
return
new
Insertable
(
$match
[
0
],
$match
[
0
]
);
},
$matches
);
$insertables
=
array_merge
(
$insertables
,
$new
);
$matches
=
[];
preg_match_all
(
'/({{((?:PLURAL|GENDER|GRAMMAR):[^|]*)
\|
).*?(}})/i'
,
$text
,
$matches
,
PREG_SET_ORDER
);
$new
=
array_map
(
static
function
(
$match
)
{
return
new
Insertable
(
$match
[
2
],
$match
[
1
],
$match
[
3
]
);
},
$matches
);
$insertables
=
array_merge
(
$insertables
,
$new
);
return
array_merge
(
$insertables
,
(
new
HtmlTagInsertablesSuggester
()
)->
getInsertables
(
$text
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 16 2026, 03:37 (12 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a8/fd/27109c4bb5eec258a99d24fb040c
Default Alt Text
MediaWikiInsertablesSuggester.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment