From 716dafe9e6840f89cbebacf7c559c2b3bf09fda2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 19 Sep 2008 18:47:47 +0000 Subject: [PATCH] Quickie example adding $wgLang->commaList() to encapsulate use of 'comma-separator' message. Fixme: being in a hurry, I didn't make it work correctly for non-UI languages. It should grab from the appropriate lang, not just wfMsgExt. --- includes/Exif.php | 2 +- includes/specials/SpecialPreferences.php | 2 +- includes/specials/SpecialUpload.php | 17 +++++------------ languages/Language.php | 11 +++++++++++ 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/includes/Exif.php b/includes/Exif.php index 3f3a1ceb4b..d5cf09cf08 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -799,7 +799,7 @@ class FormatExif { $fullTag = $tag . '-' . $subTag ; $flashMsgs[] = $this->msg( $fullTag, $subValue ); } - $tags[$tag] = implode( wfMsg( 'comma-separator' ), $flashMsgs ); + $tags[$tag] = $wgLang->commaList( $flashMsgs ); break; case 'FocalPlaneResolutionUnit': diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 03f94ab82f..fa5f7930dc 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -633,7 +633,7 @@ class PreferencesForm { $this->tableRow( wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ), - implode( wfMsg( 'comma-separator' ), $userEffectiveGroupsArray ) . + $wgLang->commaList( $userEffectiveGroupsArray ) . '
(' . implode( ' | ', $toolLinks ) . ')' ) . diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 98ccdcb07f..55d51a0947 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -328,10 +328,7 @@ class UploadForm { wfMsgExt( 'filetype-banned-type', array( 'parseinline' ), htmlspecialchars( $finalExt ), - implode( - wfMsgExt( 'comma-separator', array( 'escapenoentities' ) ), - $wgFileExtensions - ), + $wgLang->commaList( $wgFileExtensions ), $wgLang->formatNum( count($wgFileExtensions) ) ) ); @@ -520,10 +517,7 @@ class UploadForm { wfMsgExt( 'filetype-unwanted-type', array( 'parseinline' ), htmlspecialchars( $finalExt ), - implode( - wfMsgExt( 'comma-separator', array( 'escapenoentities' ) ), - $wgFileExtensions - ), + $wgLang->commaList( $wgFileExtensions ), $wgLang->formatNum( count($wgFileExtensions) ) ) . ''; } @@ -1005,21 +999,20 @@ wgUploadAutoFill = {$autofill}; $allowedExtensions = ''; if( $wgCheckFileExtensions ) { - $delim = wfMsgExt( 'comma-separator', array( 'escapenoentities' ) ); if( $wgStrictFileExtensions ) { # Everything not permitted is banned $extensionsList = '
' . - wfMsgWikiHtml( 'upload-permitted', implode( $wgFileExtensions, $delim ) ) . + wfMsgWikiHtml( 'upload-permitted', $wgLang->commaList( $wgFileExtensions ) ) . "
\n"; } else { # We have to list both preferred and prohibited $extensionsList = '
' . - wfMsgWikiHtml( 'upload-preferred', implode( $wgFileExtensions, $delim ) ) . + wfMsgWikiHtml( 'upload-preferred', $wgLang->commaList( $wgFileExtensions ) ) . "
\n" . '
' . - wfMsgWikiHtml( 'upload-prohibited', implode( $wgFileBlacklist, $delim ) ) . + wfMsgWikiHtml( 'upload-prohibited', $wgLang->commaList( $wgFileBlacklist ) ) . "
\n"; } } else { diff --git a/languages/Language.php b/languages/Language.php index 364231a3bc..4d1c414b6b 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1898,6 +1898,17 @@ class Language { } return $s; } + + /** + * Take a list of strings and build a locale-friendly comma-separated + * list, using the local comma-separator message. + * @fixme Fix this so it can work for $wgContLang too + */ + function commaList( $list ) { + return implode( + $list, + wfMsgExt( 'comma-separator', 'escape-noentities' ) ); + } /** * Truncate a string to a specified length in bytes, appending an optional -- 2.20.1