From 364f6133dbdae5060917249864a4212e7ba73113 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Sat, 27 Dec 2008 19:58:11 +0000 Subject: [PATCH] * Bug 16484 Remove an unneeded extra comma in user rights log (and other lists) ** Removed the comma from MediaWiki:and (@Translatewiki staff: no fuzzying needed) ** Special case for two messages in log ** Function description updated Based on a patch by Nakon --- CREDITS | 1 + languages/Language.php | 29 ++++++++++++++++++----------- languages/messages/MessagesEn.php | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CREDITS b/CREDITS index 6590f090e8..d9846fb3d3 100644 --- a/CREDITS +++ b/CREDITS @@ -69,6 +69,7 @@ following names for their contribution to the product. * Michael De La Rue * Mike Horvath * Mormegil +* Nakon * Nathan Larson * Nikolaos S. Karastathis * Olaf Lenz diff --git a/languages/Language.php b/languages/Language.php index 26554be916..e161298a8f 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1938,26 +1938,33 @@ class Language { /** - * For the credit list in includes/Credits.php (action=credits) + * Take a list of strings and build a locale-friendly comma-separated + * list, using the local comma-separator message. + * The last two strings are chained with an "and". * * @param $l Array * @return string */ function listToText( $l ) { $s = ''; - $m = count($l) - 1; - for ($i = $m; $i >= 0; $i--) { - if ($i == $m) { - $s = $l[$i]; - } else if ($i == $m - 1) { - $s = $l[$i] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $s; - } else { - $s = $l[$i] . $this->getMessageFromDB( 'comma-separator' ) . $s; + $m = count( $l ) - 1; + if( $m == 1 ) { + return $l[0] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $l[1]; + } + else { + for ( $i = $m; $i >= 0; $i-- ) { + if ( $i == $m ) { + $s = $l[$i]; + } else if( $i == $m - 1 ) { + $s = $l[$i] . $this->getMessageFromDB( 'and' ) . $this->getMessageFromDB( 'word-separator' ) . $s; + } else { + $s = $l[$i] . $this->getMessageFromDB( 'comma-separator' ) . $s; + } } + return $s; } - return $s; } - + /** * Take a list of strings and build a locale-friendly comma-separated * list, using the local comma-separator message. diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 3d8ec6460f..78e8a2d960 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -629,7 +629,7 @@ XHTML id names. 'mytalk' => 'My talk', 'anontalk' => 'Talk for this IP', 'navigation' => 'Navigation', -'and' => ', and', +'and' => ' and', # Metadata in edit box 'metadata_help' => 'Metadata:', -- 2.20.1