Index: trunk/extensions/EducationProgram/resources/ep.js |
— | — | @@ -8,10 +8,43 @@ |
9 | 9 | |
10 | 10 | window.educationProgram = new( function() { |
11 | 11 | |
12 | | - this.compatMode = true; |
| 12 | + this.compatMode = null; |
13 | 13 | |
14 | 14 | this.msg = function () { |
15 | | - if ( window.educationProgram.compatMode ) { |
| 15 | + // Yeah, doing it here, since "mw.loader.using( 'mediawiki.language'," |
| 16 | + // does not have mediaWiki.language loaded. |
| 17 | + if ( this.compatMode === null ) { |
| 18 | + this.compatMode = typeof window.mediaWiki.language.gender === 'undefined'; |
| 19 | + |
| 20 | + if ( window.educationProgram.compatMode ) { |
| 21 | + mw.language.gender = function( gender, forms ) { |
| 22 | + if ( !forms || forms.length === 0 ) { |
| 23 | + return ''; |
| 24 | + } |
| 25 | + forms = mw.language.preConvertPlural( forms, 2 ); |
| 26 | + if ( gender === 'male' ) { |
| 27 | + return forms[0]; |
| 28 | + } |
| 29 | + if ( gender === 'female' ) { |
| 30 | + return forms[1]; |
| 31 | + } |
| 32 | + return ( forms.length === 3 ) ? forms[2] : forms[0]; |
| 33 | + }; |
| 34 | + |
| 35 | + mw.jqueryMsg.htmlEmitter.prototype.gender = function( nodes ) { |
| 36 | + var gender; |
| 37 | + if ( nodes[0] && nodes[0].options instanceof mw.Map ){ |
| 38 | + gender = nodes[0].options.get( 'gender' ); |
| 39 | + } else { |
| 40 | + gender = nodes[0]; |
| 41 | + } |
| 42 | + var forms = nodes.slice(1); |
| 43 | + return this.language.gender( gender, forms ); |
| 44 | + }; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + if ( this.compatMode ) { |
16 | 49 | return gM.apply( this, arguments ); |
17 | 50 | } |
18 | 51 | else { |
— | — | @@ -24,35 +57,3 @@ |
25 | 58 | }; |
26 | 59 | |
27 | 60 | } ); |
28 | | - |
29 | | -mw.loader.using( 'mediawiki.language', function() { |
30 | | - window.educationProgram.compatMode = typeof window.mediaWiki.language === 'undefined'; |
31 | | - |
32 | | - if ( window.educationProgram.compatMode ) { |
33 | | - mw.language.gender = function( gender, forms ) { |
34 | | - if ( !forms || forms.length === 0 ) { |
35 | | - return ''; |
36 | | - } |
37 | | - forms = mw.language.preConvertPlural( forms, 2 ); |
38 | | - if ( gender === 'male' ) { |
39 | | - return forms[0]; |
40 | | - } |
41 | | - if ( gender === 'female' ) { |
42 | | - return forms[1]; |
43 | | - } |
44 | | - return ( forms.length === 3 ) ? forms[2] : forms[0]; |
45 | | - }; |
46 | | - |
47 | | - mw.jqueryMsg.htmlEmitter.prototype.gender = function( nodes ) { |
48 | | - var gender; |
49 | | - if ( nodes[0] && nodes[0].options instanceof mw.Map ){ |
50 | | - gender = nodes[0].options.get( 'gender' ); |
51 | | - } else { |
52 | | - gender = nodes[0]; |
53 | | - } |
54 | | - var forms = nodes.slice(1); |
55 | | - return this.language.gender( gender, forms ); |
56 | | - }; |
57 | | - } |
58 | | - |
59 | | -} ); |
\ No newline at end of file |