jenkins-bot has submitted this change and it was merged.
Change subject: Modules should be in English (while docs are not)
......................................................................
Modules should be in English (while docs are not)
Change-Id: I15c10379ab2282a508322df3914d82e1fc463a22
---
M common/ScribuntoContent.php
M common/ScribuntoContentHandler.php
2 files changed, 31 insertions(+), 7 deletions(-)
Approvals:
Siebrand: Looks good to me, approved
jenkins-bot: Verified
diff --git a/common/ScribuntoContent.php b/common/ScribuntoContent.php
index 4f777db..d0486d2 100644
--- a/common/ScribuntoContent.php
+++ b/common/ScribuntoContent.php
@@ -34,11 +34,6 @@
$text = $this->getNativeData();
$output = null;
- if ( !$options ) {
- //NOTE: use canonical options per default to produce
cacheable output
- $options =
$this->getContentHandler()->makeParserOptions( 'canonical' );
- }
-
// Get documentation, if any
$output = new ParserOutput();
$doc = Scribunto::getDocPage( $title );
@@ -50,7 +45,18 @@
if ( !$msg->isDisabled() ) {
// We need the ParserOutput for categories and
such, so we
// can't use $msg->parse().
- $output = $wgParser->parse( $msg->plain(),
$title, $options, true, true, $revId );
+ $docViewLang = $doc->getPageViewLanguage();
+ $docWikitext = '<div lang="' .
htmlspecialchars( $docViewLang->getHtmlCode() ) . '"'
+ . ' dir="' . $docViewLang->getDir() .
'">' . $msg->plain() . '</div>';
+ if ( !$options ) {
+ // NOTE: use canonical options per
default to produce cacheable output
+ $options = ContentHandler::getForTitle(
$doc )->makeParserOptions( 'canonical' );
+ } else {
+ if ( $options->getTargetLanguage() ===
null ) {
+ $options->setTargetLanguage(
$doc->getPageLanguage() );
+ }
+ }
+ $output = $wgParser->parse( $docWikitext,
$title, $options, true, true, $revId );
}
// Mark the doc page as a transclusion, so we get
purged when it
@@ -74,7 +80,7 @@
$code = $geshi->parse_code();
if( $code ) {
$output->addHeadItem(
SyntaxHighlight_GeSHi::buildHeadItem( $geshi ), "source-{$language}" );
- $output->setText( $output->getText() .
"<div dir=\"ltr\">{$code}</div>" );
+ $output->setText( $output->getText() .
$code );
return $output;
}
}
diff --git a/common/ScribuntoContentHandler.php
b/common/ScribuntoContentHandler.php
index ba1e17b..d055c8c 100644
--- a/common/ScribuntoContentHandler.php
+++ b/common/ScribuntoContentHandler.php
@@ -35,4 +35,22 @@
public function makeEmptyContent() {
return new ScribuntoContent( '' );
}
+
+ /**
+ * Scripts themselves should be in English.
+ *
+ * @return Language wfGetLangObj( 'en' )
+ */
+ public function getPageLanguage( Title $title, Content $content = null
) {
+ return wfGetLangObj( 'en' );
+ }
+
+ /**
+ * Scripts themselves should be in English.
+ *
+ * @return Language wfGetLangObj( 'en' )
+ */
+ public function getPageViewLanguage( Title $title, Content $content =
null ) {
+ return wfGetLangObj( 'en' );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/65998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I15c10379ab2282a508322df3914d82e1fc463a22
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Liangent <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Liangent <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits