Nikerabbit has uploaded a new change for review. https://gerrit.wikimedia.org/r/266243
Change subject: Improve translatable page header code ...................................................................... Improve translatable page header code Moved code for <languages /> into separate file and load styles via parser. Merge mw-translate-page-info into mw-pt-translate-header to avoid duplication. Load this for all pages with <translate> tags as well as translation pages. Include noprint class with all uses of this class. These changes make it so that styles are properly loaded for pages which have <translate> tags but are not yet marked for translation, which didn't work before this patch. Needs a follow-up after a while to remove code kept for now to avoid breaking cached pages. Change-Id: I94888f858e5ae523493ffa5dbf6431e675bdf380 --- M Resources.php M resources/css/ext.translate.css A resources/css/ext.translate.tag.languages.css M tag/PageTranslationHooks.php 4 files changed, 83 insertions(+), 73 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/43/266243/1 diff --git a/Resources.php b/Resources.php index 8064b4a..9a868a3 100644 --- a/Resources.php +++ b/Resources.php @@ -510,6 +510,11 @@ 'position' => 'top', ) + $resourcePaths; +$wgResourceModules['ext.translate.tag.languages'] = array( + 'styles' => 'resources/css/ext.translate.tag.languages.css', + 'position' => 'top', +) + $resourcePaths; + $wgResourceModules['ext.translate.translationstashstorage'] = array( 'scripts' => 'resources/js/ext.translate.translationstashstorage.js', 'dependencies' => array( diff --git a/resources/css/ext.translate.css b/resources/css/ext.translate.css index de49a98..e1a93ff 100644 --- a/resources/css/ext.translate.css +++ b/resources/css/ext.translate.css @@ -1,72 +1,4 @@ -.mw-translate-page-info { - font-size: x-small; - text-align: center; - direction: ltr; -} - -.mw-pt-languages { - display: table; - border: 1px solid rgb(170, 170, 170); - background: rgb(246, 249, 237) none repeat scroll 0 0; - border-collapse: collapse; - line-height: 1.2; - width: 100%; - clear: both; - overflow: auto; -} - -.mw-pt-languages-label { - display: table-cell; - border-right: 1px solid rgb(170, 170, 170); - padding: 0.5em; - background: rgb(238, 243, 226) none repeat scroll 0 0; - font-weight: bold; - width: 15%; -} - -.mw-pt-languages-list { - padding-left: 0.5em; - padding-bottom: 0.7em; - display: table-cell; - width: 80%; -} - -.mw-pt-languages-list a { - white-space: nowrap; -} - .mw-pt-translate-header { font-size: x-small; text-align: center; -} - -.mw-pt-languages-selected, -.mw-pt-languages-ui { - font-weight: bold; -} - -.mw-pt-progress { - padding-right: 11px; - background: transparent right center no-repeat; - background-size: 9px 9px; -} - -.mw-pt-progress--stub { - background-image: url('../images/prog-1.png'); -} - -.mw-pt-progress--low { - background-image: url('../images/prog-2.png'); -} - -.mw-pt-progress--med { - background-image: url('../images/prog-3.png'); -} - -.mw-pt-progress--high { - background-image: url('../images/prog-4.png'); -} - -.mw-pt-progress--complete { - background-image: url('../images/prog-5.png'); } diff --git a/resources/css/ext.translate.tag.languages.css b/resources/css/ext.translate.tag.languages.css new file mode 100644 index 0000000..1d308d0 --- /dev/null +++ b/resources/css/ext.translate.tag.languages.css @@ -0,0 +1,61 @@ +.mw-pt-languages { + display: table; + border: 1px solid rgb(170, 170, 170); + background: rgb(246, 249, 237) none repeat scroll 0 0; + border-collapse: collapse; + line-height: 1.2; + width: 100%; + clear: both; + overflow: auto; +} + +.mw-pt-languages-label { + display: table-cell; + border-right: 1px solid rgb(170, 170, 170); + padding: 0.5em; + background: rgb(238, 243, 226) none repeat scroll 0 0; + font-weight: bold; + width: 15%; +} + +.mw-pt-languages-list { + padding-left: 0.5em; + padding-bottom: 0.7em; + display: table-cell; + width: 80%; +} + +.mw-pt-languages-list a { + white-space: nowrap; +} + +.mw-pt-languages-selected, +.mw-pt-languages-ui { + font-weight: bold; +} + +.mw-pt-progress { + padding-right: 11px; + background: transparent right center no-repeat; + background-size: 9px 9px; +} + +.mw-pt-progress--stub { + background-image: url('../images/prog-1.png'); +} + +.mw-pt-progress--low { + background-image: url('../images/prog-2.png'); +} + +.mw-pt-progress--med { + background-image: url('../images/prog-3.png'); +} + +.mw-pt-progress--high { + background-image: url('../images/prog-4.png'); +} + +.mw-pt-progress--complete { + background-image: url('../images/prog-5.png'); +} diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php index 33339ca..0dad193 100644 --- a/tag/PageTranslationHooks.php +++ b/tag/PageTranslationHooks.php @@ -39,6 +39,8 @@ } } + $parser->getOutput()->addModules( 'ext.translate' ); + // Set display title $page = TranslatablePage::isTranslationPage( $title ); if ( !$page ) { @@ -83,14 +85,22 @@ $isTranslation = TranslatablePage::isTranslationPage( $title ); if ( $isSource || $isTranslation ) { + // Remove 30 days after merging this patch + $out->addModules( 'ext.translate.tag.languages' ); $out->addModuleStyles( 'ext.translate' ); + if ( $wgTranslatePageTranslationULS ) { $out->addModules( 'ext.translate.pagetranslation.uls' ); } - // Per bug T63331 - $type = $isSource ? 'source' : 'translation'; - $out->addJsConfigVars( 'wgTranslatePageTranslation', $type ); + if ( $isTranslation ) { + // Source pages get this module via <translate>, but for translation + // pages we need to add it manually. + $out->addModuleStyles( 'ext.translate' ); + $out->addJsConfigVars( 'wgTranslatePageTranslation', 'translation' ); + } else { + $out->addJsConfigVars( 'wgTranslatePageTranslation', 'source' ); + } } return true; @@ -313,6 +323,8 @@ $languages ); $out .= Html::closeElement( 'div' ); + + $parser->getOutput()->addModuleStyles( 'ext.translate.tag.languages' ); return $out; } @@ -765,9 +777,9 @@ $wrap = Html::rawElement( 'div', array( - 'class' => 'mw-translate-page-info', - 'lang' => $language->getHtmlCode(), + 'class' => 'mw-pt-translate-header noprint', 'dir' => $language->getDir(), + 'lang' => $language->getHtmlCode(), ), '$1' ); -- To view, visit https://gerrit.wikimedia.org/r/266243 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I94888f858e5ae523493ffa5dbf6431e675bdf380 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits