Index: trunk/phase3/resources/mediawiki.language/mediawiki.language.js |
— | — | @@ -96,6 +96,32 @@ |
97 | 97 | } |
98 | 98 | return integer ? parseInt( convertedNumber, 10 ) : convertedNumber; |
99 | 99 | }, |
| 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 | + |
100 | 126 | // Digit Transform Table, populated by language classes where applicable |
101 | 127 | 'digitTransformTable': null |
102 | 128 | }; |