Index: trunk/extensions/UploadWizard/test/jasmine/makeLanguageSpec.php |
— | — | @@ -0,0 +1,113 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This PHP script defines the spec that the Javascript message parser should conform to. |
| 6 | + * |
| 7 | + * It does this by looking up the results of various string kinds of string parsing, with various languages, |
| 8 | + * in the current installation of MediaWiki. It then outputs a static specification, mapping expected inputs to outputs, |
| 9 | + * which can be used with the JasmineBDD framework. This specification can then be used by simply including it into |
| 10 | + * the SpecRunner.html file. |
| 11 | + * |
| 12 | + * This is similar to Michael Dale (mdale@mediawiki.org)'s parser tests, except that it doesn't look up the |
| 13 | + * API results while doing the test, so the Jasmine run is much faster (at the cost of being out of date in rare |
| 14 | + * circumstances. But mostly the parsing that we are doing in Javascript doesn't change much.) |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | +$maintenanceDir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) . '/maintenance'; |
| 19 | + |
| 20 | +require( "$maintenanceDir/Maintenance.php" ); |
| 21 | + |
| 22 | +class MakeLanguageSpec extends Maintenance { |
| 23 | + |
| 24 | + static $keyToTestArgs = array( |
| 25 | + 'undelete_short' => array( |
| 26 | + array( 0 ), |
| 27 | + array( 1 ), |
| 28 | + array( 2 ), |
| 29 | + array( 5 ), |
| 30 | + array( 21 ), |
| 31 | + array( 101 ) |
| 32 | + ), |
| 33 | + 'category-subcat-count' => array( |
| 34 | + array( 0, 10 ), |
| 35 | + array( 1, 1 ), |
| 36 | + array( 1, 2 ), |
| 37 | + array( 3, 30 ) |
| 38 | + ) |
| 39 | + ); |
| 40 | + |
| 41 | + public function __construct() { |
| 42 | + parent::__construct(); |
| 43 | + $this->mDescription = "Create a JasmineBDD-compatible specification for message parsing"; |
| 44 | + // add any other options here |
| 45 | + } |
| 46 | + |
| 47 | + public function execute() { |
| 48 | + list( $messages, $tests ) = $this->getMessagesAndTests(); |
| 49 | + $this->writeJavascriptFile( $messages, $tests, "spec/mediawiki.language.parser.spec.data.js" ); |
| 50 | + } |
| 51 | + |
| 52 | + private function getMessagesAndTests() { |
| 53 | + $messages = array(); |
| 54 | + $tests = array(); |
| 55 | + $wfMsgExtOptions = array( 'parsemag' ); |
| 56 | + foreach ( array( 'en', 'fr', 'ar', 'jp', 'zh' ) as $languageCode ) { |
| 57 | + $wfMsgExtOptions['language'] = $languageCode; |
| 58 | + foreach ( self::$keyToTestArgs as $key => $testArgs ) { |
| 59 | + foreach ($testArgs as $args) { |
| 60 | + // get the raw template, without any transformations |
| 61 | + $template = wfMsgGetKey( $key, /* useDb */ true, $languageCode, /* transform */ false ); |
| 62 | + |
| 63 | + // get the magic-parsed version with args |
| 64 | + $wfMsgExtArgs = array_merge( array( $key, $wfMsgExtOptions ), $args ); |
| 65 | + $result = call_user_func_array( 'wfMsgExt', $wfMsgExtArgs ); |
| 66 | + |
| 67 | + // record the template, args, language, and expected result |
| 68 | + // fake multiple languages by flattening them together |
| 69 | + $langKey = $languageCode . '_' . $key; |
| 70 | + $messages[ $langKey ] = $template; |
| 71 | + $tests[] = array( |
| 72 | + 'name' => $languageCode . " " . $key . " " . join( ",", $args ), |
| 73 | + 'key' => $langKey, |
| 74 | + 'args' => $args, |
| 75 | + 'result' => $result, |
| 76 | + 'lang' => $languageCode |
| 77 | + ); |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + return array( $messages, $tests ); |
| 82 | + } |
| 83 | + |
| 84 | + private function writeJavascriptFile( $messages, $tests, $dataSpecFile ) { |
| 85 | + global $argv; |
| 86 | + $arguments = count($argv) ? $argv : $_SERVER[ 'argv' ]; |
| 87 | + |
| 88 | + $json = new Services_JSON; |
| 89 | + $json->pretty = true; |
| 90 | + $javascriptPrologue = "// This file stores the results from the PHP parser for certain messages and arguments,\n" |
| 91 | + . "// so we can test the equivalent Javascript libraries.\n" |
| 92 | + . '// Last generated with ' . join(' ', $arguments) . ' at ' . gmdate('c') . "\n\n"; |
| 93 | + $javascriptMessages = "mediaWiki.messages.set( " . $json->encode( $messages, true ) . " );\n"; |
| 94 | + $javascriptTests = 'var jasmineMsgSpec = ' . $json->encode( $tests, true ) . ";\n"; |
| 95 | + |
| 96 | + $fp = fopen( $dataSpecFile, 'w' ); |
| 97 | + if ( !$fp ) { |
| 98 | + die( "couldn't open $dataSpecFile for writing" ); |
| 99 | + } |
| 100 | + $success = fwrite( $fp, $javascriptPrologue . $javascriptMessages . $javascriptTests ); |
| 101 | + if ( !$success ) { |
| 102 | + die( "couldn't write to $dataSpecFile" ); |
| 103 | + } |
| 104 | + $success = fclose( $fp ); |
| 105 | + if ( !$success ) { |
| 106 | + die( "couldn't close $dataSpecFile" ); |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +$maintClass = "MakeLanguageSpec"; |
| 112 | +require_once( "$maintenanceDir/doMaintenance.php" ); |
| 113 | + |
| 114 | + |
Property changes on: trunk/extensions/UploadWizard/test/jasmine/makeLanguageSpec.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 115 | + native |
Added: svn:executable |
2 | 116 | + * |
Index: trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html |
— | — | @@ -10,20 +10,25 @@ |
11 | 11 | <script type="text/javascript" src="/w/load.php?debug=true&lang=en&modules=jquery%7Cmediawiki&only=scripts&skin=vector"></script> |
12 | 12 | <script type="text/javascript" src="lib/appendto-jquery-mockjax/jquery.mockjax.js"></script> |
13 | 13 | |
14 | | - <script type="text/javascript" src="../../resources/mw.js"></script> |
| 14 | + <script type="text/javascript" src="../../../../resources/mediawiki/mediawiki.js"></script> |
| 15 | + <script type="text/javascript" src="../../../../resources/mediawiki.language/mediawiki.language.js"></script> |
| 16 | + <script type="text/javascript" src="../../../../resources/mediawiki.language/mediawiki.language.parser.js"></script> |
| 17 | + <script type="text/javascript" src="../../../../resources/jquery/jquery.mwMessage.js"></script> |
15 | 18 | <script type="text/javascript" src="../../resources/mw.Utilities.js"></script> |
16 | 19 | <script type="text/javascript" src="../../resources/mw.Uri.js"></script> |
17 | 20 | <script type="text/javascript" src="../../resources/mw.Api.js"></script> |
18 | 21 | <script type="text/javascript" src="../../resources/mw.Api.edit.js"></script> |
19 | | - <script type="text/javascript" src="../../resources/language/mw.Language.js"></script> |
20 | | - <script type="text/javascript" src="../../resources/language/mw.Parser.js"></script> |
21 | 22 | <script type="text/javascript" src="../../resources/mw.Title.js"></script> |
22 | 23 | |
23 | 24 | <!-- include spec files here... --> |
24 | 25 | <script type="text/javascript" src="spec/mw.Uri.spec.js"></script> |
25 | 26 | <script type="text/javascript" src="spec/mw.Api.spec.js"></script> |
26 | 27 | <script type="text/javascript" src="spec/mw.Api.edit.spec.js"></script> |
27 | | - <!-- script type="text/javascript" src="spec/mw.Language.spec.js"></script> --> |
| 28 | + |
| 29 | + <script type="text/javascript" src="spec/mediawiki.language.parser.spec.data.js"></script> |
| 30 | + <script type="text/javascript" src="spec/mediawiki.language.parser.spec.js"></script> |
| 31 | + |
| 32 | + <script type="text/javascript" src="spec/jquery.mwMessage.spec.js"></script> |
28 | 33 | <script type="text/javascript" src="spec/mw.Title.spec.js"></script> |
29 | 34 | |
30 | 35 | </head> |
Index: trunk/extensions/UploadWizard/test/jasmine/spec/mediawiki.language.parser.spec.js |
— | — | @@ -2,29 +2,30 @@ |
3 | 3 | |
4 | 4 | // boilerplate crap, can we eliminate this? |
5 | 5 | |
| 6 | +/* |
6 | 7 | jQuery( document ).ready( function() { |
7 | 8 | // add "magic" to Language template parser for keywords |
8 | | - mw.addTemplateTransform( { 'SITENAME' : function() { return wgSitename; } } ); |
| 9 | + // mediaWiki.language.parser.templateProcessors.SITENAME = function() { return wgSitename; }; |
9 | 10 | |
10 | 11 | // sets up plural "magic" and so on. Seems like a bad design to have to do this, though. |
11 | | - mw.Language.magicSetup(); |
| 12 | + // mediaWiki.language.magicSetup(); |
12 | 13 | |
13 | 14 | } ); |
| 15 | +*/ |
14 | 16 | |
15 | | - |
16 | 17 | /** |
17 | 18 | * Tests |
18 | 19 | */ |
19 | | -describe( "mw.Language", function() { |
| 20 | +describe( "mediaWiki.language.parser", function() { |
20 | 21 | |
21 | 22 | |
22 | 23 | describe( "basic message functionality", function() { |
23 | | - mw.addMessages( { |
| 24 | + mediaWiki.messages.set( { |
24 | 25 | 'simple-message': 'simple message' |
25 | 26 | } ); |
26 | 27 | |
27 | 28 | it( "should return identity for simple string", function() { |
28 | | - expect( gM( 'simple-message' ) ).toEqual( 'simple message' ); |
| 29 | + expect( mediaWiki.msg( 'simple-message' ) ).toEqual( 'simple message' ); |
29 | 30 | } ); |
30 | 31 | |
31 | 32 | } ); |
— | — | @@ -34,16 +35,17 @@ |
35 | 36 | /** |
36 | 37 | * Get a language transform key |
37 | 38 | * returns default "en" fallback if none found |
| 39 | + * @FIXME the resource loader should do this anyway, should not be necessary to know this client side |
38 | 40 | * @param String langKey The language key to be checked |
39 | 41 | */ |
40 | | - mw.Language.getLangTransformKey = function( langKey ) { |
41 | | - if( mw.Language.fallbackTransformMap[ langKey ] ) { |
42 | | - langKey = mw.Language.fallbackTransformMap[ langKey ]; |
| 42 | + mediaWiki.language.getLangTransformKey = function( langKey ) { |
| 43 | + if( mediaWiki.language.fallbackTransformMap[ langKey ] ) { |
| 44 | + langKey = mediaWiki.language.fallbackTransformMap[ langKey ]; |
43 | 45 | } |
44 | 46 | // Make sure the langKey has a transformClass: |
45 | | - for( var i = 0; i < mw.Language.transformClass.length ; i++ ) { |
46 | | - if( langKey == mw.Language.transformClass[i] ){ |
47 | | - return langKey |
| 47 | + for( var i = 0; i < mediaWiki.language.transformClass.length ; i++ ) { |
| 48 | + if( langKey == mediaWiki.language.transformClass[i] ){ |
| 49 | + return langKey; |
48 | 50 | } |
49 | 51 | } |
50 | 52 | // By default return the base 'en' class |
— | — | @@ -55,7 +57,7 @@ |
56 | 58 | * so it keeps up-to-date with php maping. |
57 | 59 | * ( not explicitly listed here ) |
58 | 60 | */ |
59 | | - mw.Language.fallbackTransformMap = { |
| 61 | + mediaWiki.language.fallbackTransformMap = { |
60 | 62 | 'mwl' : 'pt', |
61 | 63 | 'ace' : 'id', |
62 | 64 | 'hsb' : 'de', |
— | — | @@ -215,7 +217,7 @@ |
216 | 218 | * @@FIXME again not needed if the resource loader manages this mapping and gives |
217 | 219 | * us the "right" transform class regardless of what language key we request. |
218 | 220 | */ |
219 | | - mw.Language.transformClass = ['am', 'ar', 'bat_smg', 'be_tarak', 'be', 'bh', |
| 221 | + mediaWiki.language.transformClass = ['am', 'ar', 'bat_smg', 'be_tarak', 'be', 'bh', |
220 | 222 | 'bs', 'cs', 'cu', 'cy', 'dsb', 'fr', 'ga', 'gd', 'gv', 'he', 'hi', |
221 | 223 | 'hr', 'hsb', 'hy', 'ksh', 'ln', 'lt', 'lv', 'mg', 'mk', 'mo', 'mt', |
222 | 224 | 'nso', 'pl', 'pt_br', 'ro', 'ru', 'se', 'sh', 'sk', 'sl', 'sma', |
— | — | @@ -224,7 +226,7 @@ |
225 | 227 | // wgLang?? |
226 | 228 | var wgLanguageCode = 'en'; |
227 | 229 | // Set-up base convert plural and gender (to restore for non-transform languages ) |
228 | | - var cachedConvertPlural = { 'en' : mw.Language.convertPlural }; |
| 230 | + var cachedConvertPlural = { 'en' : mediaWiki.language.convertPlural }; |
229 | 231 | |
230 | 232 | // XXX THIS ONLY WORKS FOR NEIL |
231 | 233 | var wgScriptPath = 'http://wiki.ivy.local/w'; |
— | — | @@ -234,17 +236,17 @@ |
235 | 237 | * @param {String} languageCode |
236 | 238 | * @param {Function} to be executed when related scripts have loaded |
237 | 239 | */ |
238 | | - mw.Language.resetForLang = function( lang, fn ) { |
239 | | - mw.Language.digitTransformTable = null; |
| 240 | + mediaWiki.language.resetForLang = function( lang, fn ) { |
| 241 | + mediaWiki.language.digitTransformTable = null; |
240 | 242 | // Load the current language js file if it has a langKey |
241 | | - var lang = mw.Language.getLangTransformKey( lang ); |
| 243 | + var lang = mediaWiki.language.getLangTransformKey( lang ); |
242 | 244 | if( cachedConvertPlural[lang] ) { |
243 | | - mw.Language.convertPlural = cachedConvertPlural[lang]; |
| 245 | + mediaWiki.language.convertPlural = cachedConvertPlural[lang]; |
244 | 246 | fn(); |
245 | 247 | } else { |
246 | 248 | mw.log( lang + " load msg transform" ); |
247 | | - $j.getScript( wgScriptPath + '/resources/mediawiki.language/languages/' + lang.toLowerCase() + '.js' , function(){ |
248 | | - cachedConvertPlural[lang] = mw.Language.convertPlural; |
| 249 | + $j.getScript( wgScriptPath + '/resources/mediaWiki.language/languages/' + lang.toLowerCase() + '.js' , function(){ |
| 250 | + cachedConvertPlural[lang] = mediaWiki.language.convertPlural; |
249 | 251 | fn(); |
250 | 252 | }); |
251 | 253 | } |
— | — | @@ -253,12 +255,10 @@ |
254 | 256 | |
255 | 257 | $j.each( jasmineMsgSpec, function( i, test ) { |
256 | 258 | it( "should parse " + test.name, function() { |
257 | | - mw.Language.resetForLang( test.lang, function() { |
| 259 | + mediaWiki.language.resetForLang( test.lang, function() { |
258 | 260 | var argArray = [ test.key ].concat( test.args ); |
259 | | - result = gM.apply( this, argArray ); |
260 | | - //if ( test.name == 'jp undelete_short 0' ) { |
261 | | - // debugger; |
262 | | - //} |
| 261 | + var parsedText = mediaWiki.language.parser.apply( this, argArray ); |
| 262 | + result = parsedText.getHTML(); |
263 | 263 | expect( result ).toEqual( test.result ); |
264 | 264 | } ); |
265 | 265 | } ); |
Index: trunk/extensions/UploadWizard/test/jasmine/spec/mediawiki.parser2.spec.js |
— | — | @@ -373,13 +373,29 @@ |
374 | 374 | it ( "should handle a simple link", function() { |
375 | 375 | var parser = new mediaWiki.language.parser(); |
376 | 376 | var parsed = parser.parse( 'en_link' ); |
377 | | - expect( parsed.html() ).toEqual( 'Simple <a href="http://example.com">link to example</a>.' ); |
| 377 | + var contents = parsed.contents(); |
| 378 | + expect( contents.length ).toEqual( 3 ); |
| 379 | + expect( contents[0].nodeName ).toEqual( '#text' ); |
| 380 | + expect( contents[0].nodeValue ).toEqual( 'Simple ' ); |
| 381 | + expect( contents[1].nodeName ).toEqual( 'A' ); |
| 382 | + expect( contents[1].getAttribute( 'href' ) ).toEqual( 'http://example.com' ); |
| 383 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'link to example' ); |
| 384 | + expect( contents[2].nodeName ).toEqual( '#text' ); |
| 385 | + expect( contents[2].nodeValue ).toEqual( '.' ); |
378 | 386 | } ); |
379 | 387 | |
380 | 388 | it ( "should replace a URL into a link", function() { |
381 | 389 | var parser = new mediaWiki.language.parser(); |
382 | 390 | var parsed = parser.parse( 'en_link_replace', [ 'http://example.com/foo', 'linking' ] ); |
383 | | - expect( parsed.html() ).toEqual( 'Complex <a href="http://example.com/foo">linking</a> behaviour.' ); |
| 391 | + var contents = parsed.contents(); |
| 392 | + expect( contents.length ).toEqual( 3 ); |
| 393 | + expect( contents[0].nodeName ).toEqual( '#text' ); |
| 394 | + expect( contents[0].nodeValue ).toEqual( 'Complex ' ); |
| 395 | + expect( contents[1].nodeName ).toEqual( 'A' ); |
| 396 | + expect( contents[1].getAttribute( 'href' ) ).toEqual( 'http://example.com/foo' ); |
| 397 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'linking' ); |
| 398 | + expect( contents[2].nodeName ).toEqual( '#text' ); |
| 399 | + expect( contents[2].nodeValue ).toEqual( ' behaviour.' ); |
384 | 400 | } ); |
385 | 401 | |
386 | 402 | it ( "should bind a click handler into a link", function() { |
— | — | @@ -390,12 +406,12 @@ |
391 | 407 | var contents = parsed.contents(); |
392 | 408 | expect( contents.length ).toEqual( 3 ); |
393 | 409 | expect( contents[0].nodeName ).toEqual( '#text' ); |
394 | | - expect( contents[0].textContent ).toEqual( 'Complex ' ); |
| 410 | + expect( contents[0].nodeValue ).toEqual( 'Complex ' ); |
395 | 411 | expect( contents[1].nodeName ).toEqual( 'A' ); |
396 | 412 | expect( contents[1].getAttribute( 'href' ) ).toEqual( '#' ); |
397 | | - expect( contents[1].textContent ).toEqual( 'linking' ); |
| 413 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'linking' ); |
398 | 414 | expect( contents[2].nodeName ).toEqual( '#text' ); |
399 | | - expect( contents[2].textContent ).toEqual( ' behaviour.' ); |
| 415 | + expect( contents[2].nodeValue ).toEqual( ' behaviour.' ); |
400 | 416 | // determining bindings is hard in IE |
401 | 417 | var anchor = parsed.find( 'a' ); |
402 | 418 | if ( ( $j.browser.mozilla || $j.browser.webkit ) && anchor.click ) { |
— | — | @@ -414,11 +430,11 @@ |
415 | 431 | var contents = parsed.contents(); |
416 | 432 | expect( contents.length ).toEqual( 3 ); |
417 | 433 | expect( contents[0].nodeName ).toEqual( '#text' ); |
418 | | - expect( contents[0].textContent ).toEqual( 'Complex ' ); |
| 434 | + expect( contents[0].nodeValue ).toEqual( 'Complex ' ); |
419 | 435 | expect( contents[1].nodeName ).toEqual( 'BUTTON' ); |
420 | | - expect( contents[1].textContent ).toEqual( 'buttoning' ); |
| 436 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'buttoning' ); |
421 | 437 | expect( contents[2].nodeName ).toEqual( '#text' ); |
422 | | - expect( contents[2].textContent ).toEqual( ' behaviour.' ); |
| 438 | + expect( contents[2].nodeValue ).toEqual( ' behaviour.' ); |
423 | 439 | // determining bindings is hard in IE |
424 | 440 | if ( ( $j.browser.mozilla || $j.browser.webkit ) && button.click ) { |
425 | 441 | expect( clicked ).toEqual( false ); |
— | — | @@ -474,9 +490,12 @@ |
475 | 491 | describe( "easy message interface functions", function() { |
476 | 492 | it( "should allow a global that returns strings", function() { |
477 | 493 | var gM = mediaWiki.language.parser.getMessageFunction(); |
| 494 | + // passing this through jQuery and back to string, because browsers may have subtle differences, like the case of tag names. |
| 495 | + // a surrounding <SPAN> is needed for html() to work right |
| 496 | + var expectedHtml = $j( '<span>Complex <a href="http://example.com/foo">linking</a> behaviour.</span>' ).html(); |
478 | 497 | var result = gM( 'en_link_replace', 'http://example.com/foo', 'linking' ); |
479 | 498 | expect( typeof result ).toEqual( 'string' ); |
480 | | - expect( result ).toEqual( 'Complex <a href="http://example.com/foo">linking</a> behaviour.' ); |
| 499 | + expect( result ).toEqual( expectedHtml ); |
481 | 500 | } ); |
482 | 501 | |
483 | 502 | it( "should allow a jQuery plugin that appends to nodes", function() { |
— | — | @@ -485,11 +504,18 @@ |
486 | 505 | var clicked = false; |
487 | 506 | var $button = $j( '<button>' ).click( function() { clicked = true; } ); |
488 | 507 | $div.find( '.foo' ).msg( 'en_link_replace', $button, 'buttoning' ); |
489 | | - expect( $div.find( '.foo' ).html() ).toEqual( 'Complex <button>buttoning</button> behaviour.' ); |
| 508 | + // passing this through jQuery and back to string, because browsers may have subtle differences, like the case of tag names. |
| 509 | + // a surrounding <SPAN> is needed for html() to work right |
| 510 | + var expectedHtml = $j( '<span>Complex <button>buttoning</button> behaviour.</span>' ).html(); |
| 511 | + var createdHtml = $div.find( '.foo' ).html(); |
| 512 | + // it is hard to test for clicks with IE; also it inserts or removes spaces around nodes when creating HTML tags, depending on their type. |
| 513 | + // so need to check the strings stripped of spaces. |
490 | 514 | if ( ( $j.browser.mozilla || $j.browser.webkit ) && $button.click ) { |
491 | | - expect( clicked ).toEqual( false ); |
| 515 | + expect( createdHtml ).toEqual( expectedHtml ); |
492 | 516 | $div.find( 'button ').click(); |
493 | 517 | expect( clicked ).toEqual( true ); |
| 518 | + } else if ( $j.browser.ie ) { |
| 519 | + expect( createdHtml.replace( /\s/, '' ) ).toEqual( expectedHtml.replace( /\s/, '' ) ); |
494 | 520 | } |
495 | 521 | delete $j.fn.msg; |
496 | 522 | } ); |
Index: trunk/extensions/UploadWizard/test/jasmine/spec/mediawiki.language.parser.spec.data.js |
— | — | @@ -0,0 +1,488 @@ |
| 2 | +// This file stores the results from the PHP parser for certain messages and arguments, |
| 3 | +// so we can test the equivalent Javascript libraries. |
| 4 | +// Last generated with makeLanguageSpec.php at 2011-01-28T02:04:09+00:00 |
| 5 | + |
| 6 | +mediaWiki.messages.set( { |
| 7 | + "en_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}", |
| 8 | + "en_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", |
| 9 | + "fr_undelete_short": "Restaurer $1 modification{{PLURAL:$1||s}}", |
| 10 | + "fr_category-subcat-count": "Cette cat\u00e9gorie comprend {{PLURAL:$2|la sous-cat\u00e9gorie|$2 sous-cat\u00e9gories, dont {{PLURAL:$1|celle|les $1}}}} ci-dessous.", |
| 11 | + "ar_undelete_short": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 {{PLURAL:$1|\u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f|\u062a\u0639\u062f\u064a\u0644\u064a\u0646|$1 \u062a\u0639\u062f\u064a\u0644\u0627\u062a|$1 \u062a\u0639\u062f\u064a\u0644|$1 \u062a\u0639\u062f\u064a\u0644\u0627}}", |
| 12 | + "ar_category-subcat-count": "{{PLURAL:$2|\u0644\u0627 \u062a\u0635\u0627\u0646\u064a\u0641 \u0641\u0631\u0639\u064a\u0629 \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a \u0641\u0642\u0637.|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 {{PLURAL:$1||\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a|\u0647\u0630\u064a\u0646 \u0627\u0644\u062a\u0635\u0646\u064a\u0641\u064a\u0646 \u0627\u0644\u0641\u0631\u0639\u064a\u064a\u0646|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0627\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u0629|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0646\u064a\u0641\u0627 \u0641\u0631\u0639\u064a\u0627|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0646\u064a\u0641 \u0641\u0631\u0639\u064a}}\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a $2.}}", |
| 13 | + "jp_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}", |
| 14 | + "jp_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", |
| 15 | + "zh_undelete_short": "\u6062\u590d\u88ab\u5220\u9664\u7684$1\u9879\u4fee\u8ba2", |
| 16 | + "zh_category-subcat-count": "{{PLURAL:$2|\u672c\u5206\u7c7b\u53ea\u6709\u4e0b\u5217\u4e00\u4e2a\u5b50\u5206\u7c7b\u3002|\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u5217$1\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u6709$2\u4e2a\u5b50\u5206\u7c7b\u3002}}" |
| 17 | +} ); |
| 18 | +var jasmineMsgSpec = [ |
| 19 | + { |
| 20 | + "name": "en undelete_short 0", |
| 21 | + "key": "en_undelete_short", |
| 22 | + "args": [ |
| 23 | + 0 |
| 24 | + ], |
| 25 | + "result": "Undelete 0 edits", |
| 26 | + "lang": "en" |
| 27 | + }, |
| 28 | + { |
| 29 | + "name": "en undelete_short 1", |
| 30 | + "key": "en_undelete_short", |
| 31 | + "args": [ |
| 32 | + 1 |
| 33 | + ], |
| 34 | + "result": "Undelete one edit", |
| 35 | + "lang": "en" |
| 36 | + }, |
| 37 | + { |
| 38 | + "name": "en undelete_short 2", |
| 39 | + "key": "en_undelete_short", |
| 40 | + "args": [ |
| 41 | + 2 |
| 42 | + ], |
| 43 | + "result": "Undelete 2 edits", |
| 44 | + "lang": "en" |
| 45 | + }, |
| 46 | + { |
| 47 | + "name": "en undelete_short 5", |
| 48 | + "key": "en_undelete_short", |
| 49 | + "args": [ |
| 50 | + 5 |
| 51 | + ], |
| 52 | + "result": "Undelete 5 edits", |
| 53 | + "lang": "en" |
| 54 | + }, |
| 55 | + { |
| 56 | + "name": "en undelete_short 21", |
| 57 | + "key": "en_undelete_short", |
| 58 | + "args": [ |
| 59 | + 21 |
| 60 | + ], |
| 61 | + "result": "Undelete 21 edits", |
| 62 | + "lang": "en" |
| 63 | + }, |
| 64 | + { |
| 65 | + "name": "en undelete_short 101", |
| 66 | + "key": "en_undelete_short", |
| 67 | + "args": [ |
| 68 | + 101 |
| 69 | + ], |
| 70 | + "result": "Undelete 101 edits", |
| 71 | + "lang": "en" |
| 72 | + }, |
| 73 | + { |
| 74 | + "name": "en category-subcat-count 0,10", |
| 75 | + "key": "en_category-subcat-count", |
| 76 | + "args": [ |
| 77 | + 0, |
| 78 | + 10 |
| 79 | + ], |
| 80 | + "result": "This category has the following 0 subcategories, out of 10 total.", |
| 81 | + "lang": "en" |
| 82 | + }, |
| 83 | + { |
| 84 | + "name": "en category-subcat-count 1,1", |
| 85 | + "key": "en_category-subcat-count", |
| 86 | + "args": [ |
| 87 | + 1, |
| 88 | + 1 |
| 89 | + ], |
| 90 | + "result": "This category has only the following subcategory.", |
| 91 | + "lang": "en" |
| 92 | + }, |
| 93 | + { |
| 94 | + "name": "en category-subcat-count 1,2", |
| 95 | + "key": "en_category-subcat-count", |
| 96 | + "args": [ |
| 97 | + 1, |
| 98 | + 2 |
| 99 | + ], |
| 100 | + "result": "This category has the following subcategory, out of 2 total.", |
| 101 | + "lang": "en" |
| 102 | + }, |
| 103 | + { |
| 104 | + "name": "en category-subcat-count 3,30", |
| 105 | + "key": "en_category-subcat-count", |
| 106 | + "args": [ |
| 107 | + 3, |
| 108 | + 30 |
| 109 | + ], |
| 110 | + "result": "This category has the following 3 subcategories, out of 30 total.", |
| 111 | + "lang": "en" |
| 112 | + }, |
| 113 | + { |
| 114 | + "name": "fr undelete_short 0", |
| 115 | + "key": "fr_undelete_short", |
| 116 | + "args": [ |
| 117 | + 0 |
| 118 | + ], |
| 119 | + "result": "Restaurer 0 modification", |
| 120 | + "lang": "fr" |
| 121 | + }, |
| 122 | + { |
| 123 | + "name": "fr undelete_short 1", |
| 124 | + "key": "fr_undelete_short", |
| 125 | + "args": [ |
| 126 | + 1 |
| 127 | + ], |
| 128 | + "result": "Restaurer 1 modification", |
| 129 | + "lang": "fr" |
| 130 | + }, |
| 131 | + { |
| 132 | + "name": "fr undelete_short 2", |
| 133 | + "key": "fr_undelete_short", |
| 134 | + "args": [ |
| 135 | + 2 |
| 136 | + ], |
| 137 | + "result": "Restaurer 2 modifications", |
| 138 | + "lang": "fr" |
| 139 | + }, |
| 140 | + { |
| 141 | + "name": "fr undelete_short 5", |
| 142 | + "key": "fr_undelete_short", |
| 143 | + "args": [ |
| 144 | + 5 |
| 145 | + ], |
| 146 | + "result": "Restaurer 5 modifications", |
| 147 | + "lang": "fr" |
| 148 | + }, |
| 149 | + { |
| 150 | + "name": "fr undelete_short 21", |
| 151 | + "key": "fr_undelete_short", |
| 152 | + "args": [ |
| 153 | + 21 |
| 154 | + ], |
| 155 | + "result": "Restaurer 21 modifications", |
| 156 | + "lang": "fr" |
| 157 | + }, |
| 158 | + { |
| 159 | + "name": "fr undelete_short 101", |
| 160 | + "key": "fr_undelete_short", |
| 161 | + "args": [ |
| 162 | + 101 |
| 163 | + ], |
| 164 | + "result": "Restaurer 101 modifications", |
| 165 | + "lang": "fr" |
| 166 | + }, |
| 167 | + { |
| 168 | + "name": "fr category-subcat-count 0,10", |
| 169 | + "key": "fr_category-subcat-count", |
| 170 | + "args": [ |
| 171 | + 0, |
| 172 | + 10 |
| 173 | + ], |
| 174 | + "result": "Cette cat\u00e9gorie comprend 10 sous-cat\u00e9gories, dont celle ci-dessous.", |
| 175 | + "lang": "fr" |
| 176 | + }, |
| 177 | + { |
| 178 | + "name": "fr category-subcat-count 1,1", |
| 179 | + "key": "fr_category-subcat-count", |
| 180 | + "args": [ |
| 181 | + 1, |
| 182 | + 1 |
| 183 | + ], |
| 184 | + "result": "Cette cat\u00e9gorie comprend la sous-cat\u00e9gorie ci-dessous.", |
| 185 | + "lang": "fr" |
| 186 | + }, |
| 187 | + { |
| 188 | + "name": "fr category-subcat-count 1,2", |
| 189 | + "key": "fr_category-subcat-count", |
| 190 | + "args": [ |
| 191 | + 1, |
| 192 | + 2 |
| 193 | + ], |
| 194 | + "result": "Cette cat\u00e9gorie comprend 2 sous-cat\u00e9gories, dont celle ci-dessous.", |
| 195 | + "lang": "fr" |
| 196 | + }, |
| 197 | + { |
| 198 | + "name": "fr category-subcat-count 3,30", |
| 199 | + "key": "fr_category-subcat-count", |
| 200 | + "args": [ |
| 201 | + 3, |
| 202 | + 30 |
| 203 | + ], |
| 204 | + "result": "Cette cat\u00e9gorie comprend 30 sous-cat\u00e9gories, dont les 3 ci-dessous.", |
| 205 | + "lang": "fr" |
| 206 | + }, |
| 207 | + { |
| 208 | + "name": "ar undelete_short 0", |
| 209 | + "key": "ar_undelete_short", |
| 210 | + "args": [ |
| 211 | + 0 |
| 212 | + ], |
| 213 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f", |
| 214 | + "lang": "ar" |
| 215 | + }, |
| 216 | + { |
| 217 | + "name": "ar undelete_short 1", |
| 218 | + "key": "ar_undelete_short", |
| 219 | + "args": [ |
| 220 | + 1 |
| 221 | + ], |
| 222 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644\u064a\u0646", |
| 223 | + "lang": "ar" |
| 224 | + }, |
| 225 | + { |
| 226 | + "name": "ar undelete_short 2", |
| 227 | + "key": "ar_undelete_short", |
| 228 | + "args": [ |
| 229 | + 2 |
| 230 | + ], |
| 231 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 2 \u062a\u0639\u062f\u064a\u0644\u0627\u062a", |
| 232 | + "lang": "ar" |
| 233 | + }, |
| 234 | + { |
| 235 | + "name": "ar undelete_short 5", |
| 236 | + "key": "ar_undelete_short", |
| 237 | + "args": [ |
| 238 | + 5 |
| 239 | + ], |
| 240 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 5 \u062a\u0639\u062f\u064a\u0644", |
| 241 | + "lang": "ar" |
| 242 | + }, |
| 243 | + { |
| 244 | + "name": "ar undelete_short 21", |
| 245 | + "key": "ar_undelete_short", |
| 246 | + "args": [ |
| 247 | + 21 |
| 248 | + ], |
| 249 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 21 \u062a\u0639\u062f\u064a\u0644\u0627", |
| 250 | + "lang": "ar" |
| 251 | + }, |
| 252 | + { |
| 253 | + "name": "ar undelete_short 101", |
| 254 | + "key": "ar_undelete_short", |
| 255 | + "args": [ |
| 256 | + 101 |
| 257 | + ], |
| 258 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 101 \u062a\u0639\u062f\u064a\u0644\u0627", |
| 259 | + "lang": "ar" |
| 260 | + }, |
| 261 | + { |
| 262 | + "name": "ar category-subcat-count 0,10", |
| 263 | + "key": "ar_category-subcat-count", |
| 264 | + "args": [ |
| 265 | + 0, |
| 266 | + 10 |
| 267 | + ], |
| 268 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 10.", |
| 269 | + "lang": "ar" |
| 270 | + }, |
| 271 | + { |
| 272 | + "name": "ar category-subcat-count 1,1", |
| 273 | + "key": "ar_category-subcat-count", |
| 274 | + "args": [ |
| 275 | + 1, |
| 276 | + 1 |
| 277 | + ], |
| 278 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a \u0641\u0642\u0637.", |
| 279 | + "lang": "ar" |
| 280 | + }, |
| 281 | + { |
| 282 | + "name": "ar category-subcat-count 1,2", |
| 283 | + "key": "ar_category-subcat-count", |
| 284 | + "args": [ |
| 285 | + 1, |
| 286 | + 2 |
| 287 | + ], |
| 288 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 2.", |
| 289 | + "lang": "ar" |
| 290 | + }, |
| 291 | + { |
| 292 | + "name": "ar category-subcat-count 3,30", |
| 293 | + "key": "ar_category-subcat-count", |
| 294 | + "args": [ |
| 295 | + 3, |
| 296 | + 30 |
| 297 | + ], |
| 298 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0647\u0630\u0647 \u0627\u06443 \u062a\u0635\u0627\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u0629\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 30.", |
| 299 | + "lang": "ar" |
| 300 | + }, |
| 301 | + { |
| 302 | + "name": "jp undelete_short 0", |
| 303 | + "key": "jp_undelete_short", |
| 304 | + "args": [ |
| 305 | + 0 |
| 306 | + ], |
| 307 | + "result": "Undelete 0 edits", |
| 308 | + "lang": "jp" |
| 309 | + }, |
| 310 | + { |
| 311 | + "name": "jp undelete_short 1", |
| 312 | + "key": "jp_undelete_short", |
| 313 | + "args": [ |
| 314 | + 1 |
| 315 | + ], |
| 316 | + "result": "Undelete one edit", |
| 317 | + "lang": "jp" |
| 318 | + }, |
| 319 | + { |
| 320 | + "name": "jp undelete_short 2", |
| 321 | + "key": "jp_undelete_short", |
| 322 | + "args": [ |
| 323 | + 2 |
| 324 | + ], |
| 325 | + "result": "Undelete 2 edits", |
| 326 | + "lang": "jp" |
| 327 | + }, |
| 328 | + { |
| 329 | + "name": "jp undelete_short 5", |
| 330 | + "key": "jp_undelete_short", |
| 331 | + "args": [ |
| 332 | + 5 |
| 333 | + ], |
| 334 | + "result": "Undelete 5 edits", |
| 335 | + "lang": "jp" |
| 336 | + }, |
| 337 | + { |
| 338 | + "name": "jp undelete_short 21", |
| 339 | + "key": "jp_undelete_short", |
| 340 | + "args": [ |
| 341 | + 21 |
| 342 | + ], |
| 343 | + "result": "Undelete 21 edits", |
| 344 | + "lang": "jp" |
| 345 | + }, |
| 346 | + { |
| 347 | + "name": "jp undelete_short 101", |
| 348 | + "key": "jp_undelete_short", |
| 349 | + "args": [ |
| 350 | + 101 |
| 351 | + ], |
| 352 | + "result": "Undelete 101 edits", |
| 353 | + "lang": "jp" |
| 354 | + }, |
| 355 | + { |
| 356 | + "name": "jp category-subcat-count 0,10", |
| 357 | + "key": "jp_category-subcat-count", |
| 358 | + "args": [ |
| 359 | + 0, |
| 360 | + 10 |
| 361 | + ], |
| 362 | + "result": "This category has the following 0 subcategories, out of 10 total.", |
| 363 | + "lang": "jp" |
| 364 | + }, |
| 365 | + { |
| 366 | + "name": "jp category-subcat-count 1,1", |
| 367 | + "key": "jp_category-subcat-count", |
| 368 | + "args": [ |
| 369 | + 1, |
| 370 | + 1 |
| 371 | + ], |
| 372 | + "result": "This category has only the following subcategory.", |
| 373 | + "lang": "jp" |
| 374 | + }, |
| 375 | + { |
| 376 | + "name": "jp category-subcat-count 1,2", |
| 377 | + "key": "jp_category-subcat-count", |
| 378 | + "args": [ |
| 379 | + 1, |
| 380 | + 2 |
| 381 | + ], |
| 382 | + "result": "This category has the following subcategory, out of 2 total.", |
| 383 | + "lang": "jp" |
| 384 | + }, |
| 385 | + { |
| 386 | + "name": "jp category-subcat-count 3,30", |
| 387 | + "key": "jp_category-subcat-count", |
| 388 | + "args": [ |
| 389 | + 3, |
| 390 | + 30 |
| 391 | + ], |
| 392 | + "result": "This category has the following 3 subcategories, out of 30 total.", |
| 393 | + "lang": "jp" |
| 394 | + }, |
| 395 | + { |
| 396 | + "name": "zh undelete_short 0", |
| 397 | + "key": "zh_undelete_short", |
| 398 | + "args": [ |
| 399 | + 0 |
| 400 | + ], |
| 401 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76840\u9879\u4fee\u8ba2", |
| 402 | + "lang": "zh" |
| 403 | + }, |
| 404 | + { |
| 405 | + "name": "zh undelete_short 1", |
| 406 | + "key": "zh_undelete_short", |
| 407 | + "args": [ |
| 408 | + 1 |
| 409 | + ], |
| 410 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76841\u9879\u4fee\u8ba2", |
| 411 | + "lang": "zh" |
| 412 | + }, |
| 413 | + { |
| 414 | + "name": "zh undelete_short 2", |
| 415 | + "key": "zh_undelete_short", |
| 416 | + "args": [ |
| 417 | + 2 |
| 418 | + ], |
| 419 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76842\u9879\u4fee\u8ba2", |
| 420 | + "lang": "zh" |
| 421 | + }, |
| 422 | + { |
| 423 | + "name": "zh undelete_short 5", |
| 424 | + "key": "zh_undelete_short", |
| 425 | + "args": [ |
| 426 | + 5 |
| 427 | + ], |
| 428 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76845\u9879\u4fee\u8ba2", |
| 429 | + "lang": "zh" |
| 430 | + }, |
| 431 | + { |
| 432 | + "name": "zh undelete_short 21", |
| 433 | + "key": "zh_undelete_short", |
| 434 | + "args": [ |
| 435 | + 21 |
| 436 | + ], |
| 437 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u768421\u9879\u4fee\u8ba2", |
| 438 | + "lang": "zh" |
| 439 | + }, |
| 440 | + { |
| 441 | + "name": "zh undelete_short 101", |
| 442 | + "key": "zh_undelete_short", |
| 443 | + "args": [ |
| 444 | + 101 |
| 445 | + ], |
| 446 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u7684101\u9879\u4fee\u8ba2", |
| 447 | + "lang": "zh" |
| 448 | + }, |
| 449 | + { |
| 450 | + "name": "zh category-subcat-count 0,10", |
| 451 | + "key": "zh_category-subcat-count", |
| 452 | + "args": [ |
| 453 | + 0, |
| 454 | + 10 |
| 455 | + ], |
| 456 | + "result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52170\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u670910\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 457 | + "lang": "zh" |
| 458 | + }, |
| 459 | + { |
| 460 | + "name": "zh category-subcat-count 1,1", |
| 461 | + "key": "zh_category-subcat-count", |
| 462 | + "args": [ |
| 463 | + 1, |
| 464 | + 1 |
| 465 | + ], |
| 466 | + "result": "\u672c\u5206\u7c7b\u53ea\u6709\u4e0b\u5217\u4e00\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 467 | + "lang": "zh" |
| 468 | + }, |
| 469 | + { |
| 470 | + "name": "zh category-subcat-count 1,2", |
| 471 | + "key": "zh_category-subcat-count", |
| 472 | + "args": [ |
| 473 | + 1, |
| 474 | + 2 |
| 475 | + ], |
| 476 | + "result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52171\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u67092\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 477 | + "lang": "zh" |
| 478 | + }, |
| 479 | + { |
| 480 | + "name": "zh category-subcat-count 3,30", |
| 481 | + "key": "zh_category-subcat-count", |
| 482 | + "args": [ |
| 483 | + 3, |
| 484 | + 30 |
| 485 | + ], |
| 486 | + "result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52173\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u670930\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 487 | + "lang": "zh" |
| 488 | + } |
| 489 | +]; |
Property changes on: trunk/extensions/UploadWizard/test/jasmine/spec/mediawiki.language.parser.spec.data.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 490 | + native |
Index: trunk/extensions/UploadWizard/resources/language/mw.Parser.js |
— | — | @@ -3,73 +3,96 @@ |
4 | 4 | */ |
5 | 5 | |
6 | 6 | // Setup swap string constants |
7 | | -var JQUERY_SWAP_STRING = 'ZjQuerySwapZ'; |
| 7 | +var JQUERY_SWAP_STRING = 'ZjQuerySwapZ'; |
8 | 8 | var LINK_SWAP_STRING = 'ZreplaceZ'; |
9 | | - |
| 9 | + |
10 | 10 | ( function( mw ) { |
11 | | - |
12 | | - // The parser magic global |
| 11 | + |
| 12 | + // The parser magic global |
13 | 13 | var pMagicSet = { }; |
14 | | - |
| 14 | + |
15 | 15 | /** |
16 | | - * addTemplateTransform to the parser |
| 16 | + * addTemplateTransform to the parser |
17 | 17 | * |
18 | 18 | * Lets you add a set template key to be transformed by a callback function |
19 | 19 | * |
20 | 20 | * @param {Object} magicSet key:callback |
21 | 21 | */ |
22 | 22 | mw.addTemplateTransform = function( magicSet ) { |
23 | | - for ( var name in magicSet ) { |
24 | | - pMagicSet[name] = magicSet[name]; |
| 23 | + for ( var i in magicSet ) { |
| 24 | + pMagicSet[ i ] = magicSet[i]; |
25 | 25 | } |
26 | 26 | }; |
27 | 27 | |
28 | 28 | /** |
29 | | - * MediaWiki wikitext "Parser" constructor |
| 29 | + * MediaWiki wikitext "Parser" constructor |
30 | 30 | * |
31 | 31 | * @param {String} wikiText the wikitext to be parsed |
32 | 32 | * @return {Object} parserObj returns a parser object that has methods for getting at |
33 | 33 | * things you would want |
34 | | - */ |
| 34 | + */ |
35 | 35 | mw.Parser = function( wikiText, options) { |
36 | 36 | // return the parserObj |
37 | | - this.init( wikiText, options ) ; |
| 37 | + this.init( wikiText, options ) ; |
| 38 | + return this; |
38 | 39 | }; |
39 | | - |
| 40 | + |
40 | 41 | mw.Parser.prototype = { |
41 | | - |
| 42 | + |
42 | 43 | // the parser output string container |
43 | 44 | pOut: false, |
44 | | - |
| 45 | + |
45 | 46 | init: function( wikiText, parserOptions ) { |
46 | | - this.wikiText = wikiText; |
47 | | - }, |
48 | | - |
| 47 | + this.wikiText = wikiText; |
| 48 | + |
| 49 | + var defaultParserOptions = { |
| 50 | + 'templateParCount' : 2 |
| 51 | + }; |
| 52 | + |
| 53 | + this.options = $j.extend( defaultParserOptions, parserOptions); |
| 54 | + }, |
| 55 | + |
49 | 56 | // Update the text value |
50 | 57 | updateText : function( wikiText ) { |
51 | 58 | this.wikiText = wikiText; |
52 | | - |
| 59 | + |
53 | 60 | // invalidate the output ( will force a re-parse ) |
54 | 61 | this.pOut = false; |
55 | 62 | }, |
56 | | - |
| 63 | + // checks if the required number of parenthesis are found |
| 64 | + // xxx this is just a stop gap solution |
| 65 | + checkParlookAheadOpen: function(text, a){ |
| 66 | + if( this.options.templateParCount == 2 ){ |
| 67 | + return ( text[a] == '{' && text[a + 1] == '{' ); |
| 68 | + } else if( this.options.templateParCount == 3 ) { |
| 69 | + return ( text[a] == '{' && text[a + 1] == '{' && text[a + 2] == '{'); |
| 70 | + } |
| 71 | + }, |
| 72 | + checkParlookAheadClose: function( text, a){ |
| 73 | + if( this.options.templateParCount == 2 ){ |
| 74 | + return ( text[a] == '}' && text[a + 1] == '}' ); |
| 75 | + } else if( this.options.templateParCount == 3 ) { |
| 76 | + return ( text[a] == '}' && text[a + 1] == '}' && text[a + 2] == '}'); |
| 77 | + } |
| 78 | + }, |
57 | 79 | /** |
58 | | - * Quickly recursive / parse out templates: |
| 80 | + * Quickly recursive / parse out templates: |
59 | 81 | */ |
60 | 82 | parse: function() { |
| 83 | + var _this = this; |
61 | 84 | function recurseTokenizeNodes ( text ) { |
62 | 85 | var node = { }; |
63 | 86 | // Inspect each char |
64 | 87 | for ( var a = 0; a < text.length; a++ ) { |
65 | | - if ( text[a] == '{' && text[a + 1] == '{' ) { |
66 | | - a = a + 2; |
| 88 | + if ( _this.checkParlookAheadOpen( text, a ) ) { |
| 89 | + a = a + _this.options.templateParCount; |
67 | 90 | node['parent'] = node; |
68 | 91 | if ( !node['child'] ) { |
69 | 92 | node['child'] = new Array(); |
70 | 93 | } |
71 | 94 | |
72 | 95 | node['child'].push( recurseTokenizeNodes( text.substr( a ) ) ); |
73 | | - } else if ( text[a] == '}' && text[a + 1] == '}' ) { |
| 96 | + } else if ( _this.checkParlookAheadClose( text, a ) ) { |
74 | 97 | a++; |
75 | 98 | if ( !node['parent'] ) { |
76 | 99 | return node; |
— | — | @@ -80,20 +103,20 @@ |
81 | 104 | node['text'] = ''; |
82 | 105 | } |
83 | 106 | // Don't put }} closures into output: |
84 | | - if ( text[a] && text[a] != '}' ) { |
| 107 | + if ( text[a] && text[a] != '}' ) { |
85 | 108 | node['text'] += text[a]; |
86 | 109 | } |
87 | 110 | } |
88 | 111 | return node; |
89 | 112 | } |
90 | | - |
| 113 | + |
91 | 114 | /** |
92 | 115 | * Parse template text as template name and named params |
93 | | - * @param {String} templateString Template String to be parsed |
| 116 | + * @param {String} templateString Template String to be parsed |
94 | 117 | */ |
95 | 118 | function parseTmplTxt( templateString ) { |
96 | 119 | var templateObject = { }; |
97 | | - |
| 120 | + |
98 | 121 | // Get template name: |
99 | 122 | templateName = templateString.split( '\|' ).shift() ; |
100 | 123 | templateName = templateName.split( '\{' ).shift() ; |
— | — | @@ -106,15 +129,15 @@ |
107 | 130 | templateObject["name"] = templateName.split( ':' ).shift(); |
108 | 131 | templateObject["arg"] = templateName.split( ':' ).pop(); |
109 | 132 | } |
110 | | - |
| 133 | + |
111 | 134 | var paramSet = templateString.split( '\|' ); |
112 | 135 | paramSet.splice( 0, 1 ); |
113 | 136 | if ( paramSet.length ) { |
114 | 137 | templateObject.param = new Array(); |
115 | | - for ( var pInx = 0; pInx < paramSet.length; pInx++ ) { |
| 138 | + for ( var pInx =0; pInx < paramSet.length; pInx++ ) { |
116 | 139 | var paramString = paramSet[ pInx ]; |
117 | 140 | // check for empty param |
118 | | - if ( paramString === '' ) { |
| 141 | + if ( paramString == '' ) { |
119 | 142 | templateObject.param[ pInx ] = ''; |
120 | 143 | continue; |
121 | 144 | } |
— | — | @@ -128,10 +151,10 @@ |
129 | 152 | } |
130 | 153 | } |
131 | 154 | } |
132 | | - } |
| 155 | + } |
133 | 156 | return templateObject; |
134 | 157 | } |
135 | | - |
| 158 | + |
136 | 159 | /** |
137 | 160 | * Get the Magic text from a template node |
138 | 161 | */ |
— | — | @@ -146,58 +169,58 @@ |
147 | 170 | return node.text; |
148 | 171 | } |
149 | 172 | } |
150 | | - |
| 173 | + |
151 | 174 | /** |
152 | 175 | * swap links of form [ ] for html a links or jquery helper spans |
153 | 176 | * NOTE: this could be integrated into the tokenizer but for now |
154 | 177 | * is a staged process. |
155 | 178 | * |
156 | | - * @param text to swapped |
| 179 | + * @param text to swapped |
157 | 180 | */ |
158 | 181 | function linkSwapText( text ) { |
159 | 182 | //mw.log( "linkSwapText::" + text ); |
160 | 183 | var re = new RegExp( /\[([^\s]+[\s]+[^\]]*)\]/g ); |
161 | 184 | var matchSet = text.match( re ); |
162 | | - |
| 185 | + |
163 | 186 | if( !matchSet ){ |
164 | 187 | return text; |
165 | | - } |
| 188 | + } |
166 | 189 | |
167 | | - text = text.replace( re , LINK_SWAP_STRING ); |
168 | | - |
| 190 | + text = text.replace( re , LINK_SWAP_STRING ); |
| 191 | + |
169 | 192 | for( var i=0; i < matchSet.length; i++ ) { |
170 | 193 | // Strip the leading [ and trailing ] |
171 | 194 | var matchParts = matchSet[i].substr(1, matchSet[i].length-2); |
172 | | - |
173 | | - // Check for special jQuery type swap and replace inner JQUERY_SWAP_STRING not value |
174 | | - if( matchParts.indexOf( JQUERY_SWAP_STRING ) !== -1 ) { |
175 | | - // parse the link as html |
176 | | - var $matchParts = $j('<span>' + matchParts + '</span>' ); |
177 | | - |
| 195 | + |
| 196 | + // Check for special jQuery type swap and replace inner JQUERY_SWAP_STRING not value |
| 197 | + if( matchParts.indexOf( JQUERY_SWAP_STRING ) !== -1 ) { |
| 198 | + // parse the link as html |
| 199 | + var $matchParts = $j('<span>' + matchParts + '</span>' ); |
| 200 | + |
178 | 201 | $jQuerySpan = $matchParts.find('#' +JQUERY_SWAP_STRING + i ); |
179 | | - |
| 202 | + |
180 | 203 | var linkText = $matchParts.text(); |
181 | 204 | //mw.log(" going to swap in linktext: " + linkText ); |
182 | 205 | $jQuerySpan.text( linkText ); |
183 | | - |
| 206 | + |
184 | 207 | text = text.replace( LINK_SWAP_STRING, $j('<span />' ).append( $jQuerySpan ).html() ); |
185 | | - } else { |
186 | | - // do text string replace |
187 | | - matchParts = matchParts.split(/ /); |
188 | | - var link = matchParts[0]; |
189 | | - matchParts.shift(); |
190 | | - var linkText = matchParts.join(' '); |
191 | | - |
192 | | - text = text.replace( LINK_SWAP_STRING, '<a href="' + link + '">' + linkText + '</a>' ); |
| 208 | + } else { |
| 209 | + // do text string replace |
| 210 | + matchParts = matchParts.split(/ /); |
| 211 | + var link = matchParts[0]; |
| 212 | + matchParts.shift(); |
| 213 | + var linkText = matchParts.join(' '); |
| 214 | + |
| 215 | + text = text.replace( LINK_SWAP_STRING, '<a href="' + link + '">' + linkText + '</a>' ); |
193 | 216 | } |
194 | 217 | } |
195 | 218 | return text; |
196 | 219 | } |
197 | | - |
| 220 | + |
198 | 221 | /** |
199 | 222 | * recurse_magic_swap |
200 | 223 | * |
201 | | - * Go last child first swap upward: |
| 224 | + * Go last child first swap upward: |
202 | 225 | */ |
203 | 226 | var pNode = null; |
204 | 227 | function recurse_magic_swap( node ) { |
— | — | @@ -206,41 +229,41 @@ |
207 | 230 | |
208 | 231 | if ( node['child'] ) { |
209 | 232 | // swap all the kids: |
210 | | - for ( var i = 0; i < node['child'].length; i++ ) { |
| 233 | + for ( var i in node['child'] ) { |
211 | 234 | var nodeText = recurse_magic_swap( node['child'][i] ); |
212 | 235 | // swap it into current |
213 | 236 | if ( node.text ) { |
214 | 237 | node.text = node.text.replace( node['child'][i].text, nodeText ); |
215 | 238 | } |
216 | 239 | // swap into parent |
217 | | - pNode.text = pNode.text.replace( node['child'][i].text, nodeText ); |
| 240 | + pNode.text = pNode.text.replace( node['child'][i].text, nodeText ); |
218 | 241 | } |
219 | 242 | // Get the updated node text |
220 | 243 | var nodeText = getMagicTxtFromTempNode( node ); |
221 | 244 | pNode.text = pNode.text.replace( node.text , nodeText ); |
222 | 245 | // return the node text |
223 | 246 | return node.text; |
224 | | - } else { |
| 247 | + } else { |
225 | 248 | return getMagicTxtFromTempNode( node ); |
226 | 249 | } |
227 | 250 | } |
228 | | - |
| 251 | + |
229 | 252 | // Parse out the template node structure: |
230 | 253 | this.pNode = recurseTokenizeNodes ( this.wikiText ); |
231 | | - |
232 | | - // Strip out the parent from the root |
| 254 | + |
| 255 | + // Strip out the parent from the root |
233 | 256 | this.pNode['parent'] = null; |
234 | | - |
| 257 | + |
235 | 258 | // Do the recursive magic swap text: |
236 | 259 | this.pOut = recurse_magic_swap( this.pNode ); |
237 | | - |
238 | | - // Do link swap |
239 | | - this.pOut = linkSwapText( this.pOut ); |
| 260 | + |
| 261 | + // Do link swap |
| 262 | + this.pOut = linkSwapText( this.pOut ); |
240 | 263 | }, |
241 | | - |
| 264 | + |
242 | 265 | /** |
243 | 266 | * templates |
244 | | - * |
| 267 | + * |
245 | 268 | * Get a requested template from the wikitext (if available) |
246 | 269 | * @param templateName |
247 | 270 | */ |
— | — | @@ -249,7 +272,7 @@ |
250 | 273 | var tmplSet = new Array(); |
251 | 274 | function getMatchingTmpl( node ) { |
252 | 275 | if ( node['child'] ) { |
253 | | - for ( var i = 0; i < node['child'].length; i++ ) { |
| 276 | + for ( var i in node['child'] ) { |
254 | 277 | getMatchingTmpl( node['child'] ); |
255 | 278 | } |
256 | 279 | } |
— | — | @@ -263,53 +286,53 @@ |
264 | 287 | getMatchingTmpl( this.pNode ); |
265 | 288 | return tmplSet; |
266 | 289 | }, |
267 | | - |
| 290 | + |
268 | 291 | /** |
269 | 292 | * getTemplateVars |
270 | 293 | * returns a set of template values in a given wikitext page |
271 | | - * |
| 294 | + * |
272 | 295 | * NOTE: should be integrated with the usability wikitext parser |
273 | 296 | */ |
274 | 297 | getTemplateVars: function() { |
275 | 298 | //mw.log('matching against: ' + wikiText); |
276 | 299 | templateVars = new Array(); |
277 | 300 | var tempVars = wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi); |
278 | | - |
| 301 | + |
279 | 302 | // Clean up results: |
280 | 303 | for(var i=0; i < tempVars.length; i++) { |
281 | | - //match |
| 304 | + //match |
282 | 305 | var tvar = tempVars[i].replace('{{{','').replace('}}}',''); |
283 | | - |
| 306 | + |
284 | 307 | // Strip anything after a | |
285 | 308 | if(tvar.indexOf('|') != -1) { |
286 | 309 | tvar = tvar.substr(0, tvar.indexOf('|')); |
287 | 310 | } |
288 | | - |
| 311 | + |
289 | 312 | // Check for duplicates: |
290 | 313 | var do_add=true; |
291 | 314 | for(var j=0; j < templateVars.length; j++) { |
292 | 315 | if( templateVars[j] == tvar) |
293 | 316 | do_add=false; |
294 | 317 | } |
295 | | - |
| 318 | + |
296 | 319 | // Add the template vars to the output obj |
297 | 320 | if(do_add) |
298 | 321 | templateVars.push( tvar ); |
299 | 322 | } |
300 | 323 | return templateVars; |
301 | 324 | }, |
302 | | - |
| 325 | + |
303 | 326 | /** |
304 | 327 | * Returns the transformed wikitext |
305 | | - * |
306 | | - * Build output from swappable index |
307 | | - * (all transforms must be expanded in parse stage and linearly rebuilt) |
308 | | - * Alternatively we could build output using a place-holder & replace system |
| 328 | + * |
| 329 | + * Build output from swappable index |
| 330 | + * (all transforms must be expanded in parse stage and linearly rebuilt) |
| 331 | + * Alternatively we could build output using a place-holder & replace system |
309 | 332 | * (this lets us be slightly more sloppy with ordering and indexes, but probably slower) |
310 | | - * |
311 | | - * Ideal: we build a 'wiki DOM' |
| 333 | + * |
| 334 | + * Ideal: we build a 'wiki DOM' |
312 | 335 | * When editing you update the data structure directly |
313 | | - * Then in output time you just go DOM->html-ish output without re-parsing anything |
| 336 | + * Then in output time you just go DOM->html-ish output without re-parsing anything |
314 | 337 | */ |
315 | 338 | getHTML: function() { |
316 | 339 | // wikiText updates should invalidate pOut |
— | — | @@ -319,5 +342,5 @@ |
320 | 343 | return this.pOut; |
321 | 344 | } |
322 | 345 | }; |
323 | | - |
324 | | -}) ( window.mediaWiki ); |
| 346 | + |
| 347 | +}) ( window.mw ); |
\ No newline at end of file |