r41431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41430‎ | r41431 | r41432 >
Date:17:15, 30 September 2008
Author:ialex
Status:old (Comments)
Tags:
Comment:
Fix for r41430: wfMsgExt() now accepts a Language object in the language key of $options
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -676,9 +676,9 @@
677677 * <i>parsemag</i>: transform the message using magic phrases
678678 * <i>content</i>: fetch message for content language instead of interface
679679 * Also can accept a single associative argument, of the form 'language' => 'xx':
680 - * <i>language</i>: language code to fetch message for (overriden by
681 - * <i>content</i>), its behaviour with parser, parseinline and parsemag
682 - * is undefined.
 680+ * <i>language</i>: Language object or language code to fetch message for
 681+ * (overriden by <i>content</i>), its behaviour with parser, parseinline
 682+ * and parsemag is undefined.
683683 * Behavior for conflicting options (e.g., parse+parseinline) is undefined.
684684 */
685685 function wfMsgExt( $key, $options ) {
@@ -706,12 +706,7 @@
707707 $langCode = true;
708708 } elseif( array_key_exists('language', $options) ) {
709709 $forContent = false;
710 - $langCode = $options['language'];
711 - $validCodes = array_keys( Language::getLanguageNames() );
712 - if( !in_array($options['language'], $validCodes) ) {
713 - # Fallback to en, instead of whatever interface language we might have
714 - $langCode = 'en';
715 - }
 710+ $langCode = wfGetLangObj( $options['language'] );
716711 } else {
717712 $forContent = false;
718713 $langCode = false;
Index: trunk/phase3/languages/Language.php
@@ -1903,33 +1903,23 @@
19041904 * Take a list of strings and build a locale-friendly comma-separated
19051905 * list, using the local comma-separator message.
19061906 * @param $list array of strings to put in a comma list
1907 - * @param $forContent bool Use $wgContentLang instead of the UI lang
19081907 * @return string
19091908 */
19101909 function commaList( $list, $forContent = false ) {
1911 - $params = array( 'escapenoentities' );
1912 - if ( $forContent === true ) {
1913 - $params[] = 'content';
1914 - }
19151910 return implode(
19161911 $list,
1917 - wfMsgExt( 'comma-separator', $params ) );
 1912+ wfMsgExt( 'comma-separator', array( 'escapenoentities', 'language' => $this ) ) );
19181913 }
19191914
19201915 /**
19211916 * Same as commaList, but separate it with the pipe instead.
19221917 * @param $list array of strings to put in a pipe list
1923 - * @param $forContent bool Use $wgContentLang instead of the UI lang
19241918 * @return string
19251919 */
1926 - function pipeList( $list, $forContent = false ) {
1927 - $params = array( 'escapenoentities' );
1928 - if ( $forContent === true ) {
1929 - $params[] = 'content';
1930 - }
 1920+ function pipeList( $list ) {
19311921 return implode(
19321922 $list,
1933 - wfMsgExt( 'pipe-separator', $params ) );
 1923+ wfMsgExt( 'pipe-separator', array( 'escapenoentities', 'language' => $this ) ) );
19341924 }
19351925
19361926 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r41438Tweak for r41431: also use wfMsgExt() in Language::getMessageFromDB()ialex19:03, 30 September 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41430* Add $forContent option to Language::commaList...demon16:24, 30 September 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   20:23, 30 September 2008

Looks good!

Status & tagging log