3 <title>Test Plural Conversions (should match php)
</title>
4 <script type=
"text/javascript" src=
"../mv_embed.js"></script>
7 border:solid thin black;
10 <script type=
"text/javascript" >
11 var scriptLoaderURID = 't10';
12 //for just setting one or two to test at a time for debug
13 var langKeyDebug = ['fr'];
15 //shortLangKey is an array of at least one language from every group in cldrConverter.php
16 var langKeyGroups = ['en','az', 'da', 'pt', 'fr', 'lv', 'ga','hr','cy','mk','mt','pl','sl'];
18 //longlangKey is every language we have a much more verbose test
20 //no plurals, there are no rules
21 'az','fa','hu','ja','ko','my to','tr','vi','yo','zh',
22 'bo','dz','id','jv ka','km','kn','ms','th',
29 'few' =
> array( 'mod' =
> 100, 'is'=
>'
3-
10' ),
31 'many' =
> array( 'mod' =
> 100, 'is'=
>'
11-
99')
38 'da','de','el','en','eo','es','et','fi','fo','gl',
39 'he','iw','it','nb','nl','nn','no','pt_PT','sv',
40 'af','bg','bn','ca','eu','fur','fy','gu','ha',
41 'is','ku','lb','ml','mr','nah','ne','om','or',
42 'pa','pap','ps','so','sq','sw','ta','te','tk',
48 'pt','am','bh','fil','tl','guw','hi','ln','mg','nso','ti','wa',
51 'one' =
> array( 'is'=
>'
0-
2', 'not' =
> 2)
57 //n mod
10 is
1 and n mod
100 is not
11
59 array( 'mod' =
> 10, 'is' =
> 1 ),
61 array( 'mod' =
> 100, 'not' =
> 11)
70 'ga','se','sma','smi','smj','smn','sms',
75 //n is
0 OR n is not
1 AND n mod
100 in
1.
.19
82 array( 'mod' =
> 100, 'is'=
>'
1-
19')
91 //n mod
10 is
1 and n mod
100 not in
11.
.19
93 array( 'mod'=
>10, 'is'=
> 1 ),
94 array( 'mod'=
> 100, 'not'=
> '
11-
19')
96 //n mod
10 in
2.
.9 and n mod
100 not in
11.
.19
98 array( 'mod'=
> 10, 'is'=
> '
2-
9' ),
99 array( 'mod'=
> 100, 'not' =
> '
11-
19')
106 //n mod
10 is
1 and n mod
100 is not
11
108 array( 'mod' =
> 10, 'is' =
> 1),
109 array( 'mod' =
> 100, 'not' =
> 11)
111 //n mod
10 in
2.
.4 and n mod
100 not in
12.
.14
113 array( 'mod' =
> 10, 'is' =
> '
2-
4'),
114 array( 'mod' =
> 100, 'not' =
> '
12-
14')
116 //n mod
10 is
0 or n mod
10 in
5.
.9 or n mod
100 in
11.
.14
119 array( 'mod'=
> 10, 'is' =
> 0),
120 array( 'mod'=
> 10, 'is' =
> '
5-
9'),
121 array( 'mod'=
> 100, 'is' =
> '
11-
14')
125 'hr','ru','sr','uk','be','bs','sh',
132 array( 'mod' =
> 10, 'is' =
> '
2-
4'),
133 //and n mod
100 not in
12.
.14
134 array( 'mod' =
> 100, 'not'=
> '
12-
14'),
135 //and n mod
100 not in
22.
.24
136 array( 'mod' =
> 100, 'in' =
> '
22-
24')
142 'one' =
> array( 'mod'=
>100, 'is' =
> 1 ),
143 'two' =
> array( 'mod'=
>100, 'is' =
> 2 ),
144 'few' =
> array( 'mod'=
>100, 'is' =
> '
3-
4')
151 //n is
0 or n mod
100 in
2.
.10
155 array( 'mod' =
> 100, 'is' =
> '
2-
10')
157 //n mod
100 in
11.
.19
158 'many' =
> array( 'mod'=
>100, 'is' =
> '
11-
19')
163 'one' =
> array('mod' =
> 10, 'is' =
> '
1')
178 js2AddOnloadHook( function(){
179 //do mauall script loaders calls to test multiple languages:
180 function doLangTable(langSet){
181 //build table output:
183 'undelete_short': [
0,
1,
2,
5,
21,
30 ],
184 //category-subcat-count' has two params:
185 'category-subcat-count' : [
195 $j.each(langSet, function(na, langKey){
196 js_log('load language key: ' + langKey);
197 //do a manual call to the script-lodaer:
198 js_log('do load: ' + '../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&lang='+langKey );
199 $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&lang='+langKey, function(){
201 o+='
<tr><td colspan=
"6" height=
"20" style=
"font-size:large"><b>Lang:' + langKey + '
</b></td></tr>';
202 //now for each langage msg:
203 $j.each(msgTestSet, function(mKey, mTestSet){
204 //output table names:
207 '
<td width=
"14%">Msg key
</td>'+
208 '
<td width=
"34%">Msg text
</td>'+
209 '
<td width=
"24%">Msg Transform JS
</td>'+
210 '
<td width=
"24%">Msg Transform Mw
</td>'+
213 //for each number value
214 for(var i in mTestSet){
215 var numVal = mTestSet[i];
216 var numKey = (typeof numVal== 'object')? numVal.join( '_' ).replace('/ /', '_') : numVal;
217 var tkey = mKey + '_' + numKey + '_' + langKey;
219 '
<td>' + numVal + '
</td>' +
220 '
<td>' + mKey + '
</td>' +
221 '
<td>' + $mw.lang.gMsgNoTrans( mKey ) + '
</td>' +
222 '
<td id=
"' + tkey + '_js">' + $mw.lang.gM( mKey, numVal ) + '
</td>';
224 if( mKey.substr(
0,
5) == 'test_' ){
225 o+='
<td> (test msg)
</td>';
227 o+='
<td id=
"' + tkey + '">loading...
</td>';
229 //get transform from mw (& compare and highlight)
230 function doPopWmMsg(mKey, numVal, numKey){
231 //set the local tkey:
232 var tkey = mKey + '_' + numKey + '_' + langKey;
234 $j('#score_card').html('Running Tests
<span id=
"perc_done">0</sapn>% done');
235 var msgparam = (typeof numVal== 'object')? numVal.join( '|' ) : numVal;
240 'text' : '{{int:' + mKey + '|' + msgparam + '}}'
242 'url' : '../../../api.php'
243 }, function( data ) {
245 if(data.parse && data.parse.text && data.parse.text['*']){
246 $j(t).html( data.parse.text['*'] );
247 var js_txt = $j.trim( $j(t + '_js').text().replace('\n', '') );
248 var php_txt = $j.trim( $j(t + ' p').text())
249 //just get the part in the
<p> to compare with js version
250 if( js_txt != php_txt ){
251 var cat = $j.trim( $j(t + ' p').text() );
252 var dog = $j.trim( $j(t + '_js').text() );
256 $j(t).css('color', 'red');
259 $j(t).css('color', 'green');
262 var perc = ( failTest + passTest ) / testCount
264 $j('#perc_done').html( Math.round(perc*
1000)/
1000 + '%');
266 var failHtlm = (failTest ==
0)?failTest: '
<span style=
"color:red">'+ failTest+'
</span>';
267 $j('#score_card').html(
268 'Passed:
<span style=
"color:green">' + passTest + '
</span> Failed:' + failHtlm );
275 //pop off an anonymous function call
276 doPopWmMsg(mKey, numVal, numKey);
281 o+='
<tr><td colspan=
"6" height=
"20"> </td></tr>';
283 //put the output into the page:
284 $j('#table_out').append( o );
288 //by default run the
"debug" set:
289 doLangTable( langKeyDebug );
295 <h3>Test Javascript plural msg transformations
</h3>
296 <div id=
"score_card" style=
"font-size:large"></div>
297 <table id=
"table_out"></table>