Quickie example adding $wgLang->commaList() to encapsulate use of 'comma-separator...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 19 Sep 2008 18:47:47 +0000 (18:47 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 19 Sep 2008 18:47:47 +0000 (18:47 +0000)
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
includes/specials/SpecialPreferences.php
includes/specials/SpecialUpload.php
languages/Language.php

index 3f3a1ce..d5cf09c 100644 (file)
@@ -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':
index 03f94ab..fa5f793 100644 (file)
@@ -633,7 +633,7 @@ class PreferencesForm {
 
                        $this->tableRow(
                                wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ),
-                               implode( wfMsg( 'comma-separator' ), $userEffectiveGroupsArray ) .
+                               $wgLang->commaList( $userEffectiveGroupsArray ) .
                                '<br />(' . implode( ' | ', $toolLinks ) . ')'
                        ) .
 
index 98ccdcb..55d51a0 100644 (file)
@@ -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) )
                                        ) . '</li>';
                                }
@@ -1005,21 +999,20 @@ wgUploadAutoFill = {$autofill};
 
                $allowedExtensions = '';
                if( $wgCheckFileExtensions ) {
-                       $delim = wfMsgExt( 'comma-separator', array( 'escapenoentities' ) );
                        if( $wgStrictFileExtensions ) {
                                # Everything not permitted is banned
                                $extensionsList =
                                        '<div id="mw-upload-permitted">' .
-                                       wfMsgWikiHtml( 'upload-permitted', implode( $wgFileExtensions, $delim ) ) .
+                                       wfMsgWikiHtml( 'upload-permitted', $wgLang->commaList( $wgFileExtensions ) ) .
                                        "</div>\n";
                        } else {
                                # We have to list both preferred and prohibited
                                $extensionsList =
                                        '<div id="mw-upload-preferred">' .
-                                       wfMsgWikiHtml( 'upload-preferred', implode( $wgFileExtensions, $delim ) ) .
+                                       wfMsgWikiHtml( 'upload-preferred', $wgLang->commaList( $wgFileExtensions ) ) .
                                        "</div>\n" .
                                        '<div id="mw-upload-prohibited">' .
-                                       wfMsgWikiHtml( 'upload-prohibited', implode( $wgFileBlacklist, $delim ) ) .
+                                       wfMsgWikiHtml( 'upload-prohibited', $wgLang->commaList( $wgFileBlacklist ) ) .
                                        "</div>\n";
                        }
                } else {
index 364231a..4d1c414 100644 (file)
@@ -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