r107808 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107807‎ | r107808 | r107809 >
Date:09:08, 2 January 2012
Author:santhosh
Status:ok (Comments)
Tags:
Comment:
Add gender support. This method is useful only if we have parser that can understand gender at client side.
Test cases and mw.jqueryMsg changes in next commit.
Modified paths:
  • /trunk/phase3/resources/mediawiki.language/mediawiki.language.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.language/mediawiki.language.js
@@ -96,6 +96,32 @@
9797 }
9898 return integer ? parseInt( convertedNumber, 10 ) : convertedNumber;
9999 },
 100+ /**
 101+ * Provides an alternative text depending on specified gender.
 102+ * Usage {{gender:username|masculine|feminine|neutral}}.
 103+ * If second or third parameter are not specified, masculine is used.
 104+ *
 105+ * These details may be overriden per language.
 106+ *
 107+ * @param gender string
 108+ * @param forms array List of gender forms
 109+ *
 110+ * @return string
 111+ */
 112+ 'gender': function( gender, forms ) {
 113+ if ( !forms || forms.length == 0 ) {
 114+ return '';
 115+ }
 116+ forms = mw.language.preConvertPlural( forms, 2 );
 117+ if ( gender === 'male' ) {
 118+ return forms[0];
 119+ }
 120+ if ( gender === 'female' ) {
 121+ return forms[1];
 122+ }
 123+ return ( forms.length == 3 ) ? forms[2] : forms[0];
 124+ },
 125+
100126 // Digit Transform Table, populated by language classes where applicable
101127 'digitTransformTable': null
102128 };

Follow-up revisions

RevisionCommit summaryAuthorDate
r107810Use strict comparison for length property....santhosh09:21, 2 January 2012
r107811Make mw.jqueryMsg understand gender....santhosh09:44, 2 January 2012

Comments

#Comment by Krinkle (talk | contribs)   09:13, 2 January 2012

Please use strict comparison for the length property.

Status & tagging log