From a11a33f787009d87e2e67d29a2980520bdd8ac47 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 30 Sep 2008 16:24:23 +0000 Subject: [PATCH] * Add $forContent option to Language::commaList * Add pipeList() for similar lists separated by pipes * More docs. --- languages/Language.php | 28 ++++++++++++++++++++++++--- languages/messages/MessagesEn.php | 1 + maintenance/language/messageTypes.inc | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index fa485d1427..4c878d0137 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1902,12 +1902,34 @@ class Language { /** * 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 + * @param $list array of strings to put in a comma list + * @param $forContent bool Use $wgContentLang instead of the UI lang + * @return string + */ + function commaList( $list, $forContent = false ) { + $params = array( 'escapenoentities' ); + if ( $forContent === true ) { + $params[] = 'content'; + } + return implode( + $list, + wfMsgExt( 'comma-separator', $params ) ); + } + + /** + * Same as commaList, but separate it with the pipe instead. + * @param $list array of strings to put in a pipe list + * @param $forContent bool Use $wgContentLang instead of the UI lang + * @return string */ - function commaList( $list ) { + function pipeList( $list, $forContent = false ) { + $params = array( 'escapenoentities' ); + if ( $forContent === true ) { + $params[] = 'content'; + } return implode( $list, - wfMsgExt( 'comma-separator', 'escapenoentities' ) ); + wfMsgExt( 'pipe-separator', $params ) ); } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 2dbefc6275..7f66051d70 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3437,6 +3437,7 @@ $1', 'comma-separator' => ', ', # only translate this message to other languages if you have to change it 'colon-separator' => ': ', # only translate this message to other languages if you have to change it 'autocomment-prefix' => '- ', # only translate this message to other languages if you have to change it +'pipe-separator' => '|', # only translate this message to other languages if you have to change it # Multipage image navigation 'imgmultipageprev' => '← previous page', diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 1feeeb1f6d..6b77ec9721 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -315,6 +315,7 @@ $wgOptionalMessages = array( 'comma-separator', 'colon-separator', 'autocomment-prefix', + 'pipe-separator', 'listgrouprights-right-display', 'timezone-utc', 'whatlinkshere-backlink', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 91ccfc2b33..2cfbb9a496 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2566,6 +2566,7 @@ $wgMessageStructure = array( 'comma-separator', 'colon-separator', 'autocomment-prefix', + 'pipe-separator', ), 'imgmulti' => array( 'imgmultipageprev', -- 2.20.1