Index: branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js |
— | — | @@ -17,18 +17,6 @@ |
18 | 18 | test( "Grammar Test", function() { |
19 | 19 | expect( opt.test.length); |
20 | 20 | for ( var i= 0 ; i < opt.test.length; i++ ) { |
21 | | - var langData = mw.language.data; |
22 | | - var grammarForms = []; |
23 | | - if ( langData[opt.language] === undefined ) { |
24 | | - langData[opt.language] = new mw.Map(); |
25 | | - }else{ |
26 | | - grammarForms = langData[opt.language].get( 'grammarForms' ); |
27 | | - } |
28 | | - if ( grammarForms[ opt.test[i].grammarForm ] === undefined ) { |
29 | | - grammarForms[ opt.test[i].grammarForm ] = [] ; |
30 | | - } |
31 | | - grammarForms[opt.test[i].grammarForm][opt.test[i].word] = opt.test[i].expected ; |
32 | | - langData[opt.language].set( 'grammarForms', grammarForms ); |
33 | 21 | equal( mw.language.convertGrammar( opt.test[i].word, opt.test[i].grammarForm ), opt.test[i].expected, opt.test[i].description ); |
34 | 22 | } |
35 | 23 | } ); |
— | — | @@ -36,13 +24,6 @@ |
37 | 25 | } |
38 | 26 | |
39 | 27 | mw.language.grammartest({ |
40 | | - language: 'en', |
41 | | - test: [ |
42 | | - { word: 'pen', grammarForm: 'genitive', expected: 'pen\'s', description: 'Grammar test for English' } |
43 | | - ] |
44 | | -}); |
45 | | - |
46 | | -mw.language.grammartest({ |
47 | 28 | language: 'bs', |
48 | 29 | test: [ |
49 | 30 | { word: 'word', grammarForm: 'instrumental', expected: 's word', description: 'Grammar test for Bosnian, instrumental case' }, |
— | — | @@ -67,3 +48,13 @@ |
68 | 49 | { word: 'word', grammarForm: 'lokatiw', expected: 'wo word', description: 'Grammar test for Upper Sorbian, lokatiw case' } |
69 | 50 | ] |
70 | 51 | }); |
| 52 | + |
| 53 | +mw.language.grammartest({ |
| 54 | + language: 'hy', |
| 55 | + test: [ |
| 56 | + { word: 'Մաունա', grammarForm: 'genitive', expected: 'Մաունայի', description: 'Grammar test for Armenian, genitive case' }, |
| 57 | + { word: 'հետո', grammarForm: 'genitive', expected: 'հետոյի', description: 'Grammar test for Armenian, genitive case' }, |
| 58 | + { word: 'գիրք', grammarForm: 'genitive', expected: 'գրքի', description: 'Grammar test for Armenian, genitive case' }, |
| 59 | + { word: 'ժամանակի', grammarForm: 'genitive', expected: 'ժամանակիի', description: 'Grammar test for Armenian, genitive case' } |
| 60 | + ] |
| 61 | +}); |
Index: branches/jsgrammar/resources/mediawiki.language/languages/bs.js |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | }; |
22 | 22 | |
23 | 23 | mediaWiki.language.convertGrammar = function( word, form ) { |
24 | | - var grammarForms = mw.language.data[ mw.config.get( 'wgContentLanguage' )].get( 'grammarForms' ); |
| 24 | + var grammarForms = mw.language.data[ 'bs' ].get( 'grammarForms' ); |
25 | 25 | if ( grammarForms && grammarForms[form] ) { |
26 | 26 | return grammarForms[form][word] ; |
27 | 27 | } |
Index: branches/jsgrammar/resources/mediawiki.language/languages/hsb.js |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | |
22 | 22 | mediaWiki.language.convertGrammar = function( word, form ) { |
23 | | - var grammarForms = mw.language.data[ mw.config.get( 'wgContentLanguage' )].get( 'grammarForms' ); |
| 23 | + var grammarForms = mw.language.data[ 'hsb' ].get( 'grammarForms' ); |
24 | 24 | if ( grammarForms && grammarForms[form] ) { |
25 | 25 | return grammarForms[form][word] ; |
26 | 26 | } |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | word = 'z ' + word; |
30 | 30 | break; |
31 | 31 | case 'lokatiw': // lokatiw |
32 | | - $word = 'wo ' + word; |
| 32 | + word = 'wo ' + word; |
33 | 33 | break; |
34 | 34 | } |
35 | 35 | return word; |
Index: branches/jsgrammar/resources/mediawiki.language/languages/hy.js |
— | — | @@ -6,3 +6,27 @@ |
7 | 7 | forms = mediaWiki.language.preConvertPlural( forms, 2 ); |
8 | 8 | return ( Math.abs( count ) <= 1 ) ? forms[0] : forms[1]; |
9 | 9 | }; |
| 10 | + |
| 11 | +mediaWiki.language.convertGrammar = function( word, form ) { |
| 12 | + var grammarForms = mw.language.data[ 'hy' ].get( 'grammarForms' ); |
| 13 | + if ( grammarForms && grammarForms[form] ) { |
| 14 | + return grammarForms[form][word] ; |
| 15 | + } |
| 16 | + |
| 17 | + // These rules are not perfect, but they are currently only used for site names so it doesn't |
| 18 | + // matter if they are wrong sometimes. Just add a special case for your site name if necessary. |
| 19 | + |
| 20 | + switch ( form ) { |
| 21 | + case 'genitive': // սեռական հոլով |
| 22 | + if ( word.substr( -1 ) === 'ա' ) |
| 23 | + word = word.substr( 0, word.length -1 ) + 'այի'; |
| 24 | + else if ( word.substr( -1 ) === 'ո' ) |
| 25 | + word = word.substr( 0, word.length - 1 ) + 'ոյի'; |
| 26 | + else if ( word.substr( -4 ) === 'գիրք' ) |
| 27 | + word = word.substr( 0, word.length - 4 ) + 'գրքի'; |
| 28 | + else |
| 29 | + word = word + 'ի'; |
| 30 | + break; |
| 31 | + } |
| 32 | + return word; |
| 33 | +}; |
Index: branches/jsgrammar/resources/mediawiki.language/languages/he.js |
— | — | @@ -14,8 +14,8 @@ |
15 | 15 | }; |
16 | 16 | |
17 | 17 | mediaWiki.language.convertGrammar = function( word, form ) { |
18 | | - var grammarForms = mw.config.get( 'wgGrammarForms' ); |
19 | | - if ( grammarForms && grammarForms['he'] && grammarForms['he'][form] ) { |
| 18 | + var grammarForms = mw.language.data[ 'he' ].get( 'grammarForms' ); |
| 19 | + if ( grammarForms && grammarForms[form] ) { |
20 | 20 | return grammarForms[form][word] ; |
21 | 21 | } |
22 | 22 | switch ( form ) { |