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 + ) . '' - . Html::element( 'caption', array(), $context->msg( 'templatedata-doc-params' ) ) + . Html::element( + 'caption', + array(), + wfMessage( 'templatedata-doc-params' )->inLanguage( $lang ) + ) . '' - . Html::element( 'th', array( 'colspan' => 2 ), $context->msg( 'templatedata-doc-param-name' ) ) - . Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-desc' ) ) - . Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-type' ) ) - . Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-default' ) ) - . Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-status' ) ) + . Html::element( + 'th', + array( 'colspan' => 2 ), + wfMessage( 'templatedata-doc-param-name' )->inLanguage( $lang ) + ) + . Html::element( + 'th', + array(), + wfMessage( 'templatedata-doc-param-desc' )->inLanguage( $lang ) + ) + . Html::element( + 'th', + array(), + wfMessage( 'templatedata-doc-param-type' )->inLanguage( $lang ) + ) + . Html::element( + 'th', + array(), + wfMessage( 'templatedata-doc-param-default' )->inLanguage( $lang ) + ) + . Html::element( + 'th', + array(), + wfMessage( 'templatedata-doc-param-status' )->inLanguage( $lang ) + ) . '' . '';