mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 14:06:52 +00:00
ApiVisualEditor: Support preloading from i18n messages
The `preload` parameter currently does not work with i18n
messages, as pages representing those messages are known, but
do not exist. Resolve this by running any NS_MEDIAWIKI page
through wfMessage() first.
This feature will be used by Personalized praise in GrowthExperiments,
which requires the preload from i18n messages capability. As a benefit,
it also makes it easier to create i18n'ed preload-based systems
(one can create MediaWiki:Foo, MediaWiki:Foo/cs and MediaWiki:Foo/de);
MediaWiki will select the best language version automatically.
MediaWiki core equivalent is uploaded as
I693bcaf71d7b8557c63538a426d7a6bd4c3edf3d.
Bug: T330337
Change-Id: I961ff7ae2263e61161e686107d80bdafa3fe3c32
(cherry picked from commit c4839e21fb
)
This commit is contained in:
parent
a767625ab4
commit
bb54369c4c
|
@ -169,6 +169,21 @@ class ApiVisualEditor extends ApiBase {
|
|||
// fall back to the corresponding page in a suitable language
|
||||
$preloadTitle = $this->getTargetTitleIfSpecialMyLanguage( $preloadTitle );
|
||||
|
||||
if ( $preloadTitle && $preloadTitle->getNamespace() == NS_MEDIAWIKI ) {
|
||||
// When the preload source is in NS_MEDIAWIKI, get the content via the i18n system, to
|
||||
// enable preloading from i18n messages. The message framework can work with normal
|
||||
// pages in NS_MEDIAWIKI, so this does not restrict preloading only to i18n messages.
|
||||
$msg = $this->msg( $preloadTitle->getText() );
|
||||
|
||||
if ( $msg->isDisabled() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $msg->params( $params )
|
||||
->inContentLanguage()
|
||||
->text();
|
||||
}
|
||||
|
||||
// Check for existence to avoid getting MediaWiki:Noarticletext
|
||||
if (
|
||||
$preloadTitle instanceof Title &&
|
||||
|
|
Loading…
Reference in a new issue