Index: trunk/extensions/Storyboard/Storyboard.i18n.php |
— | — | @@ -59,6 +59,9 @@ |
60 | 60 | 'storyboard-alreadyexists' => '"$1" is already taken.', |
61 | 61 | 'storyboard-changetitle' => 'Change the title.', |
62 | 62 | 'storyboard-notsubmitted' => 'Authentication failed, no story has been saved.', |
| 63 | + 'storyboard-charstomany' => '$1 characters to many!', |
| 64 | + 'storyboard-morecharsneeded' => '$1 more characters needed', |
| 65 | + 'storyboard-charactersleft' => '$1 characters left', |
63 | 66 | |
64 | 67 | // Story review |
65 | 68 | 'storyreview' => 'Story review', |
Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php |
— | — | @@ -55,6 +55,8 @@ |
56 | 56 | $maxLen = array_key_exists( 'maxlength', $args ) && is_int( $args['maxlength'] ) ? $args['maxlength'] : $egStoryboardMaxStoryLen; |
57 | 57 | $minLen = array_key_exists( 'minlength', $args ) && is_int( $args['minlength'] ) ? $args['minlength'] : $egStoryboardMinStoryLen; |
58 | 58 | |
| 59 | + efStoryboardAddJSLocalisation( $parser ); |
| 60 | + |
59 | 61 | // Loading a seperate JS file would be overkill for just these 3 lines, and be bad for performance. |
60 | 62 | $parser->getOutput()->addHeadItem( |
61 | 63 | <<<EOT |
Index: trunk/extensions/Storyboard/storyboard.js |
— | — | @@ -8,6 +8,21 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | |
| 12 | +function stbMsg( key ) { |
| 13 | + return wgStbMessages[key]; |
| 14 | +} |
| 15 | + |
| 16 | +function stbMsgExt( key, values ) { |
| 17 | + var message = stbMsg( key ); |
| 18 | + |
| 19 | + var n = values.length; |
| 20 | + for ( var i = 0; i < n; i++ ) { |
| 21 | + message = message.replace( '$' + ( i + 1 ), values[i] ); |
| 22 | + } |
| 23 | + |
| 24 | + return message; |
| 25 | +} |
| 26 | + |
12 | 27 | /** |
13 | 28 | * Story submission/editting functions |
14 | 29 | */ |
— | — | @@ -41,14 +56,14 @@ |
42 | 57 | var textlength = text.length; |
43 | 58 | var info = document.getElementById( infodiv ); |
44 | 59 | |
45 | | - if(textlength > upperLimit) { |
46 | | - info.innerHTML = -( upperLimit - textlength ) + ' characters to many!'; // TODO: i18n |
| 60 | + if( textlength > upperLimit ) { |
| 61 | + info.innerHTML = stbMsgExt( 'storyboard-charstomany', [-( upperLimit - textlength )] ); |
47 | 62 | return false; |
48 | | - } else if (textlength < lowerLimit) { |
49 | | - info.innerHTML = '('+ ( lowerLimit - textlength ) + ' more characters needed)'; // TODO: i18n |
| 63 | + } else if ( textlength < lowerLimit ) { |
| 64 | + info.innerHTML = stbMsgExt( 'storyboard-morecharsneeded', [lowerLimit - textlength] ); |
50 | 65 | return false; |
51 | 66 | } else { |
52 | | - info.innerHTML = '(' + ( upperLimit - textlength ) + ' characters left)'; // TODO: i18n |
| 67 | + info.innerHTML = stbMsgExt( 'storyboard-charactersleft', [upperLimit - textlength] ); |
53 | 68 | return true; |
54 | 69 | } |
55 | 70 | } |
Index: trunk/extensions/Storyboard/Storyboard.php |
— | — | @@ -132,3 +132,27 @@ |
133 | 133 | return true; |
134 | 134 | } |
135 | 135 | |
| 136 | +function efStoryboardAddJSLocalisation( $parser = false ) { |
| 137 | + wfLoadExtensionMessages( 'Storyboard' ); |
| 138 | + |
| 139 | + $messages = array( |
| 140 | + 'storyboard-charstomany', |
| 141 | + 'storyboard-morecharsneeded', |
| 142 | + 'storyboard-charactersleft' |
| 143 | + ); |
| 144 | + |
| 145 | + $data = array(); |
| 146 | + |
| 147 | + foreach ( $messages as $msg ) { |
| 148 | + $data[$msg] = wfMsgNoTrans( $msg ); |
| 149 | + } |
| 150 | + |
| 151 | + $js = 'var wgStbMessages = ' . json_encode( $data ) . ';'; |
| 152 | + |
| 153 | + if ( $parser ) { |
| 154 | + $parser->getOutput()->addHeadItem( Html::inlineScript( $js ) ); |
| 155 | + } else { |
| 156 | + global $wgOut; |
| 157 | + $wgOut->addInlineScript( $js ); |
| 158 | + } |
| 159 | +} |
\ No newline at end of file |