diff --git a/TemplateData.hooks.php b/TemplateData.hooks.php index 25d29219..c21b5e59 100644 --- a/TemplateData.hooks.php +++ b/TemplateData.hooks.php @@ -78,8 +78,6 @@ class TemplateDataHooks { */ public static function render( $input, $args, $parser, $frame ) { $ti = TemplateDataBlob::newFromJSON( $input ); - // TODO: Is there a better context? - $context = RequestContext::getMain(); $status = $ti->getStatus(); if ( !$status->isOK() ) { @@ -91,6 +89,6 @@ class TemplateDataHooks { $parser->getOutput()->addModules( 'ext.templateData' ); - return $ti->getHtml( $context ); + return $ti->getHtml( $parser->getOptions()->getUserLangObj() ); } } diff --git a/TemplateDataBlob.php b/TemplateDataBlob.php index 21d9cecd..949063a5 100644 --- a/TemplateDataBlob.php +++ b/TemplateDataBlob.php @@ -344,23 +344,49 @@ class TemplateDataBlob { return json_encode( $this->data ); } - public function getHtml( IContextSource $context ) { + public function getHtml( Language $lang ) { global $wgContLang; $langCode = $wgContLang->getCode(); $data = $this->data; $html = Html::openElement( 'div', array( 'class' => 'mw-templatedata-doc-wrap' ) ) - . Html::element( 'p', array( - 'class' => 'mw-templatedata-doc-desc' - ), $data->description->$langCode ) + . Html::element( + 'p', + array( 'class' => 'mw-templatedata-doc-desc' ), + $data->description->$langCode + ) . '