TTO has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/332031 )
Change subject: Allow CJK languages to specify flag spacing for enhanced change lists ...................................................................... Allow CJK languages to specify flag spacing for enhanced change lists Even in a monospaced font, the width of a regular space (U+0020) is not the same as the width of a CJK character. This causes enhanced changes lists, like RecentChanges, to appear jagged/misaligned, because the different flag markers at the beginning of each line do not align. This change gives CJK languages the opportunity to specify a custom space character to use for aligning the flags. The $nothing parameter to ChangesList::recentChangesFlags is set to '' in a few extensions, but other than that it is not used, so it is safe to change it to a boolean. Bug: T135575 Change-Id: I4ddc1499ee18320e645c935806b44e2226ef5ab4 --- M includes/DefaultSettings.php M includes/changes/ChangesList.php M includes/changes/OldChangesList.php M languages/i18n/en.json M languages/i18n/qqq.json 5 files changed, 40 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/31/332031/1 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 856a3f9..6193503 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -6802,6 +6802,9 @@ * $wgRecentChangesFlags['flag'] => [ * // message for the letter displayed next to rows on changes lists * 'letter' => 'letter-msg', + * // message for the space displayed in the corresponding "column" in + * // change rows which do not have this flag + * 'space' => 'space-msg', * // message for the tooltip of the letter * 'title' => 'tooltip-msg', * // optional (defaults to 'tooltip-msg'), message to use in the legend box @@ -6820,12 +6823,14 @@ $wgRecentChangesFlags = [ 'newpage' => [ 'letter' => 'newpageletter', + 'space' => 'newpagespace', 'title' => 'recentchanges-label-newpage', 'legend' => 'recentchanges-legend-newpage', 'grouping' => 'any', ], 'minor' => [ 'letter' => 'minoreditletter', + 'space' => 'minoreditspace', 'title' => 'recentchanges-label-minor', 'legend' => 'recentchanges-legend-minor', 'class' => 'minoredit', @@ -6833,6 +6838,7 @@ ], 'bot' => [ 'letter' => 'boteditletter', + 'space' => 'boteditspace', 'title' => 'recentchanges-label-bot', 'legend' => 'recentchanges-legend-bot', 'class' => 'botedit', @@ -6840,6 +6846,7 @@ ], 'unpatrolled' => [ 'letter' => 'unpatrolledletter', + 'space' => 'unpatrolledspace', 'title' => 'recentchanges-label-unpatrolled', 'legend' => 'recentchanges-legend-unpatrolled', 'grouping' => 'any', diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 77038ed..6949b9b 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -132,16 +132,19 @@ /** * Returns the appropriate flags for new page, minor change and patrolling + * * @param array $flags Associative array of 'flag' => Bool - * @param string $nothing To use for empty space + * @param bool $blanksAsSpaces Set to false for no blanks between flags. This + * parameter was a string before 1.29, so some callers set it to an empty + * string for the same effect as passing false. * @return string */ - public function recentChangesFlags( $flags, $nothing = ' ' ) { + public function recentChangesFlags( $flags, $blanksAsSpaces = true ) { $f = ''; foreach ( array_keys( $this->getConfig()->get( 'RecentChangesFlags' ) ) as $flag ) { - $f .= isset( $flags[$flag] ) && $flags[$flag] - ? self::flag( $flag, $this->getContext() ) - : $nothing; + if ( $blanksAsSpaces || ( isset( $flags[$flag] ) && $flags[$flag] ) ) { + $f .= self::flag( $flag, $this->getContext(), isset( $flags[$flag] ) && $flags[$flag] ); + } } return $f; @@ -176,14 +179,17 @@ } /** - * Make an "<abbr>" element for a given change flag. The flag indicating a new page, minor edit, - * bot edit, or unpatrolled edit. In English it typically contains "N", "m", "b", or "!". + * Make an "<abbr>" element for a given change. The flag indicating a new page, + * minor edit, bot edit, or unpatrolled edit. In English it typically contains + * "N", "m", "b", or "!". * * @param string $flag One key of $wgRecentChangesFlags * @param IContextSource $context + * @param bool $showFlag True to emit the actual flag character, false to emit + * the appropriate space * @return string HTML */ - public static function flag( $flag, IContextSource $context = null ) { + public static function flag( $flag, IContextSource $context = null, $showFlag = true ) { static $map = [ 'minoredit' => 'minor', 'botedit' => 'bot' ]; static $flagInfos = null; @@ -192,6 +198,7 @@ $flagInfos = []; foreach ( $wgRecentChangesFlags as $key => $value ) { $flagInfos[$key]['letter'] = $value['letter']; + $flagInfos[$key]['space'] = $value['space']; $flagInfos[$key]['title'] = $value['title']; // Allow customized class name, fall back to flag name $flagInfos[$key]['class'] = isset( $value['class'] ) ? $value['class'] : $key; @@ -206,10 +213,14 @@ } $info = $flagInfos[$flag]; - return Html::element( 'abbr', [ - 'class' => $info['class'], - 'title' => wfMessage( $info['title'] )->setContext( $context )->text(), - ], wfMessage( $info['letter'] )->setContext( $context )->text() ); + if ( $showFlag ) { + return Html::element( 'abbr', [ + 'class' => $info['class'], + 'title' => wfMessage( $info['title'] )->setContext( $context )->text(), + ], wfMessage( $info['letter'] )->setContext( $context )->text() ); + } else { + return wfMessage( $info['space'] )->setContext( $context )->text(); + } } /** diff --git a/includes/changes/OldChangesList.php b/includes/changes/OldChangesList.php index 8eb06ce..df95ab4 100644 --- a/includes/changes/OldChangesList.php +++ b/includes/changes/OldChangesList.php @@ -75,7 +75,7 @@ $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] ); $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'] ); $flags = $this->recentChangesFlags( [ 'unpatrolled' =>$unpatrolled, - 'bot' => $rc->mAttribs['rc_bot'] ], '' ); + 'bot' => $rc->mAttribs['rc_bot'] ], false ); if ( $flags !== '' ) { $html .= ' ' . $flags; } @@ -96,7 +96,7 @@ 'unpatrolled' => $unpatrolled, 'bot' => $rc->mAttribs['rc_bot'] ], - '' + false ); $html .= $this->getArticleLink( $rc, $unpatrolled, $watched ); } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 671dce7..ee2232d 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1405,9 +1405,13 @@ "hide": "Hide", "show": "Show", "minoreditletter": "m", + "minoreditspace": " ", "newpageletter": "N", + "newpagespace": " ", "boteditletter": "b", + "boteditspace": " ", "unpatrolledletter": "!", + "unpatrolledspace": " ", "number_of_watching_users_RCview": "[$1]", "number_of_watching_users_pageview": "[$1 watching {{PLURAL:$1|user|users}}]", "rc_categories": "Limit to categories (separate with \"|\"):", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 2f16979..eac390f 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1590,9 +1590,13 @@ "hide": "{{doc-actionlink}}\nOption text in [[Special:RecentChanges]], and in [[Special:WhatLinksHere]].\n\nSee also:\n* {{msg-mw|Show}}\n{{Identical|Hide}}", "show": "{{doc-actionlink}}\nOption text in [[Special:RecentChanges]], and in [[Special:WhatLinksHere]].\n\nSee also:\n* {{msg-mw|Hide}}\n{{Identical|Show}}", "minoreditletter": "Very short form of \"'''minor edit'''\". Used in [[Special:RecentChanges]], [[Special:Watchlist]], [[Special:Contributions]] and history pages.", + "minoreditspace": "{{optional}}\n\nOne or more spacing characters to match the length of {{msg-mw|minoreditletter}}. In place of a regular ASCII space, use <nowiki> </nowiki>.\n\nExamples:\n* If {{msg-mw|minoreditletter}} contains two Latin letters, set this message to <nowiki>  </nowiki>.\n* If {{msg-mw|minoreditletter}} contains a CJK character, this message should contain an ideographic space.", "newpageletter": "Very short form of \"'''new page'''\". Used in [[Special:RecentChanges]], [[Special:Watchlist]] and [[Special:Contributions]].", + "newpagespace": "{{optional}}\n\nOne or more spacing characters to match the length of {{msg-mw|newpageletter}}. In place of a regular ASCII space, use <nowiki> </nowiki>.\n\nExamples:\n* If {{msg-mw|newpageletter}} contains two Latin letters, set this message to <nowiki>  </nowiki>.\n* If {{msg-mw|newpageletter}} contains a CJK character, this message should contain an ideographic space.", "boteditletter": "Abbreviation of \"'''bot'''\". Appears in [[Special:RecentChanges]] and [[Special:Watchlist]].", + "boteditspace": "{{optional}}\n\nOne or more spacing characters to match the length of {{msg-mw|boteditletter}}. In place of a regular ASCII space, use <nowiki> </nowiki>.\n\nExamples:\n* If {{msg-mw|boteditletter}} contains two Latin letters, set this message to <nowiki>  </nowiki>.\n* If {{msg-mw|boteditletter}} contains a CJK character, this message should contain an ideographic space.", "unpatrolledletter": "{{optional}}\n\nUsed in {{msg-mw|Recentchanges-label-legend}}, meaning \"unpatrolled\".", + "unpatrolledspace": "{{optional}}\n\nOne or more spacing characters to match the length of {{msg-mw|unpatrolledletter}}. In place of a regular ASCII space, use <nowiki> </nowiki>.\n\nExamples:\n* If {{msg-mw|unpatrolledletter}} contains two Latin letters, set this message to <nowiki>  </nowiki>.\n* If {{msg-mw|unpatrolledletter}} contains a CJK character, this message should contain an ideographic space.", "number_of_watching_users_RCview": "{{notranslate}}\nParameters:\n* $1 - number of users who are watching", "number_of_watching_users_pageview": "Used if <code>$wgPageShowWatchingUsers</code> is true.\n* $1 - number of watching user(s)", "rc_categories": "A label of an input box. Appears on Special:RecentChanges if filtering recent changes by category is enabled (that is, $wgAllowCategorizedRecentChanges is set to true).", -- To view, visit https://gerrit.wikimedia.org/r/332031 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ddc1499ee18320e645c935806b44e2226ef5ab4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: TTO <at.li...@live.com.au> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits