Nikerabbit has uploaded a new change for review. https://gerrit.wikimedia.org/r/147643
Change subject: Shorten the html output of <language/> ...................................................................... Shorten the html output of <language/> Moved images to CSS, cleaned up the html a bit and added the translated page title to title attribute of the link. Change-Id: I5ab2d70cccddfee1e54d1bf7df2ce05938fcb8e2 --- M i18n/pagetranslation/en.json M i18n/pagetranslation/qqq.json M resources/css/ext.translate.css M tag/PageTranslationHooks.php 4 files changed, 72 insertions(+), 33 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/43/147643/1 diff --git a/i18n/pagetranslation/en.json b/i18n/pagetranslation/en.json index ee48edf..10d2231 100644 --- a/i18n/pagetranslation/en.json +++ b/i18n/pagetranslation/en.json @@ -63,6 +63,7 @@ "tpt-languages-legend": "Other languages:", "tpt-languages-separator": " • ", "tpt-languages-zero": "Start translation for this language", + "tpt-languages-nonzero": "$1 ($2% translated)", "tpt-tab-translate": "Translate", "tpt-target-page": "This page cannot be updated manually.\nThis page is a translation of the page [[$1]] and the translation can be updated using [$2 the translation tool].", "tpt-unknown-page": "This namespace is reserved for content page translations.\nThe page you are trying to edit does not seem to correspond any page marked for translation.", diff --git a/i18n/pagetranslation/qqq.json b/i18n/pagetranslation/qqq.json index 662b244..07d7f27 100644 --- a/i18n/pagetranslation/qqq.json +++ b/i18n/pagetranslation/qqq.json @@ -75,6 +75,7 @@ "tpt-languages-legend": "The caption of a language selector displayed using <code><nowiki><languages /></nowiki></code>. e.g. on [[Project list]].\n{{Identical|Otherlanguages}}", "tpt-languages-separator": "{{optional}}", "tpt-languages-zero": "Tooltip for a link in <code><nowiki><language /></nowiki></code> when language is included because it is a priority language, but translation does not yet exist.\n\nThe link directly points to the translation view ([[Special:Translate]]).\n\nTranslate this as \"Start translating (the page) into this language\".", + "tpt-languages-nonzero": "Tooltip for a link to go to a translated version of a translatable page.\n\nParameters:\n* $1 page title (translated if present)\n* $2: translation percentage", "tpt-tab-translate": "Used as label for the tab.\n\nReplaces the edit tab with translation tab for translation pages.\n{{Identical|Translate}}", "tpt-target-page": "Message displayed when trying to edit a translatable page directly. Parameters:\n* $1 is the translatable page\n* $2 is a link to the translation tool for the translatable page.", "tpt-unknown-page": "See [[mw:Help:Extension:Translate/Translation example]] for context on page translation feature.", diff --git a/resources/css/ext.translate.css b/resources/css/ext.translate.css index ebf2ed2..de49a98 100644 --- a/resources/css/ext.translate.css +++ b/resources/css/ext.translate.css @@ -31,11 +31,42 @@ 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 { +.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 f23382a..2c96979 100644 --- a/tag/PageTranslationHooks.php +++ b/tag/PageTranslationHooks.php @@ -242,29 +242,6 @@ $name = TranslateUtils::getLanguageName( $code, $code ); $name = htmlspecialchars( $name ); // Unlikely, but better safe - /* Percentages are too accurate and take more - * space than simple images */ - $percent *= 100; - if ( $percent < 20 ) { - $image = 1; - } elseif ( $percent < 40 ) { - $image = 2; - } elseif ( $percent < 60 ) { - $image = 3; - } elseif ( $percent < 80 ) { - $image = 4; - } else { - $image = 5; - } - - $percentImage = Xml::element( 'img', array( - 'src' => TranslateUtils::assetPath( "resources/images/prog-$image.png" ), - 'alt' => wfMessage( 'percent', $percent )->text(), - 'title' => wfMessage( 'percent', $percent )->text(), - 'width' => '9', - 'height' => '9', - ) ); - // Add links to other languages $suffix = ( $code === $sourceLanguage ) ? '' : "/$code"; $targetTitleString = $pageTitle->getDBkey() . $suffix; @@ -279,15 +256,42 @@ $classes[] = 'mw-pt-languages-selected'; } - if ( count( $classes ) ) { - $attribs = array( 'class' => implode( ' ', $classes ) ); - $name = Html::rawElement( 'span', $attribs, $name ); - } - if ( $currentTitle->equals( $subpage ) ) { - // No further processing needed + if ( $classes ) { + $name = Html::rawElement( 'span', array( 'class' => $classes ), $name ); + } } elseif ( $subpage->isKnown() ) { - $name = Linker::linkKnown( $subpage, $name ); + $pagename = $page->getPageDisplayTitle( $code ); + if ( !is_string( $pagename ) ) { + $pagename = $subpage->getPrefixedText(); + } + + $classes[] = 'mw-pt-progress'; + /* Percentages are too accurate and take more + * space than simple images */ + $percent *= 100; + if ( $percent < 20 ) { + $classes[] = 'mw-pt-progress--stub'; + } elseif ( $percent < 40 ) { + $classes[] = 'mw-pt-progress--low'; + } elseif ( $percent < 60 ) { + $classes[] = 'mw-pt-progress--med'; + } elseif ( $percent < 80 ) { + $classes[] = 'mw-pt-progress--high'; + } else { + $classes[] = 'mw-pt-progress--complete'; + } + + $title = wfMessage( 'tpt-languages-nonzero' ) + ->params( $pagename ) + ->numParams( $percent ) + ->text(); + $attribs = array( + 'title' => $title, + 'class' => $classes, + ); + + $name = Linker::linkKnown( $subpage, $name, $attribs ); } else { /* When language is included because it is a priority language, * but translation does not yet exists, link directly to the @@ -298,14 +302,16 @@ 'language' => $code, 'task' => 'view' ); + + $classes[] = 'new'; // For red link color $attribs = array( 'title' => wfMessage( 'tpt-languages-zero' )->text(), - 'class' => 'new', // For red link color + 'class' => $classes, ); $name = Linker::link( $specialTranslateTitle, $name, $attribs, $params ); } - $languages[] = "$name $percentImage"; + $languages[] = $name; } // dirmark (rlm/lrm) is added, because languages with RTL names can -- To view, visit https://gerrit.wikimedia.org/r/147643 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5ab2d70cccddfee1e54d1bf7df2ce05938fcb8e2 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