mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 14:36:51 +00:00
Make content language data available to VE
We have a use case in which the client needs to be able to use language utilities in the content language (footnote markers), so the data must be wired through. This will only be done in VE, and in the special case that the interface language != the content language. Bug: T369613 Change-Id: I2c10e1e36ba594da98e0efa433dd9e1a25aae6fe
This commit is contained in:
parent
e22dc3c08b
commit
08969af51c
|
@ -117,7 +117,11 @@
|
|||
"ve.ui.MWCitationContextItem.js",
|
||||
"ve.ui.MWCitationAction.js",
|
||||
"ve.ui.MWReference.init.js",
|
||||
"ve.ui.MWCitationNeededContextItem.js"
|
||||
"ve.ui.MWCitationNeededContextItem.js",
|
||||
{
|
||||
"name": "ve.ui.contentLanguage.js",
|
||||
"callback": "Cite\\ResourceLoader\\ContentLanguage::makeScript"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
"ve.ui.MWReferenceDialog.less",
|
||||
|
|
29
src/ResourceLoader/ContentLanguage.php
Normal file
29
src/ResourceLoader/ContentLanguage.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Cite\ResourceLoader;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\ResourceLoader as RL;
|
||||
|
||||
/**
|
||||
* Callback to deliver language data for the content language, if different than the interface language.
|
||||
*
|
||||
* @copyright 2024 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
||||
* @license MIT
|
||||
*/
|
||||
class ContentLanguage {
|
||||
public static function makeScript( RL\Context $context ): string {
|
||||
$contentLang = MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$contentLangCode = $contentLang->getCode();
|
||||
$interfaceLangCode = $context->getLanguage();
|
||||
|
||||
if ( $contentLangCode === $interfaceLangCode ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return 'mw.language.setData('
|
||||
. $context->encodeJson( $contentLangCode ) . ','
|
||||
. $context->encodeJson( $contentLang->getJsData() )
|
||||
. ');';
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue