r111910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111909‎ | r111910 | r111911 >
Date:05:38, 20 February 2012
Author:santhosh
Status:resolved (Comments)
Tags:i18nreview 
Comment:
Port grammar rules of dsb, hu, ga to javascript with qunit tests
Minor whitespace fixes in mediawiki.language.test.js
Small variable fix fi , follow up r111744
Modified paths:
  • /branches/jsgrammar/resources/Resources.php (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/dsb.js (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/fi.js (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/ga.js (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/hu.js (added) (history)
  • /branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js (modified) (history)

Diff [purge]

Index: branches/jsgrammar/tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js
@@ -5,7 +5,6 @@
66 ok( mw.language, 'mw.language defined' );
77 } );
88
9 -
109 mw.language.grammartest = function( options ) {
1110 var opt = $.extend({
1211 language: '',
@@ -29,7 +28,7 @@
3029 { word: 'word', grammarForm: 'instrumental', expected: 's word', description: 'Grammar test for Bosnian, instrumental case' },
3130 { word: 'word', grammarForm: 'lokativ', expected: 'o word', description: 'Grammar test for Bosnian, lokativ case' }
3231 ]
33 -});
 32+});
3433
3534 mw.language.grammartest({
3635 language: 'he',
@@ -40,7 +39,7 @@
4140 { word: 'Wikipedia', grammarForm: 'תחילית', expected: '־Wikipedia', description: 'Grammar test for Hebrew, Add a hyphen (maqaf) before non-Hebrew letters' }
4241 { word: '1995', grammarForm: 'תחילית', expected: '־1995', description: 'Grammar test for Hebrew, Add a hyphen (maqaf) before numbers' }
4342 ]
44 -});
 43+});
4544
4645 mw.language.grammartest({
4746 language: 'hsb',
@@ -48,9 +47,17 @@
4948 { word: 'word', grammarForm: 'instrumental', expected: 'z word', description: 'Grammar test for Upper Sorbian, instrumental case' },
5049 { word: 'word', grammarForm: 'lokatiw', expected: 'wo word', description: 'Grammar test for Upper Sorbian, lokatiw case' }
5150 ]
52 -});
 51+});
5352
5453 mw.language.grammartest({
 54+ language: 'dsb',
 55+ test: [
 56+ { word: 'word', grammarForm: 'instrumental', expected: 'z word', description: 'Grammar test for Lower Sorbian, instrumental case' },
 57+ { word: 'word', grammarForm: 'lokatiw', expected: 'wo word', description: 'Grammar test for Lower Sorbian, lokatiw case' }
 58+ ]
 59+});
 60+
 61+mw.language.grammartest({
5562 language: 'hy',
5663 test: [
5764 { word: 'Մաունա', grammarForm: 'genitive', expected: 'Մաունայի', description: 'Grammar test for Armenian, genitive case' },
@@ -83,4 +90,22 @@
8491 { word: 'доводы', grammarForm: 'genitive', expected: 'доводов', description: 'Grammar test for Russian, genitive case' },
8592 { word: 'песчаник', grammarForm: 'genitive', expected: 'песчаника', description: 'Grammar test for Russian, genitive case' }
8693 ]
87 -});
 94+});
 95+
 96+mw.language.grammartest({
 97+ language: 'hu',
 98+ test: [
 99+ { word: 'Wikipédiá', grammarForm: 'rol', expected: 'Wikipédiáról', description: 'Grammar test for Hungarian, rol case' },
 100+ { word: 'Wikipédiá', grammarForm: 'ba', expected: 'Wikipédiába', description: 'Grammar test for Hungarian, ba case' },
 101+ { word: 'Wikipédiá', grammarForm: 'k', expected: 'Wikipédiák', description: 'Grammar test for Hungarian, k case' },
 102+ ]
 103+});
 104+
 105+mw.language.grammartest({
 106+ language: 'ga',
 107+ test: [
 108+ { word: 'an Domhnach', grammarForm: 'ainmlae', expected: 'Dé Domhnaigh', description: 'Grammar test for Irish, ainmlae case' },
 109+ { word: 'an Luan', grammarForm: 'ainmlae', expected: 'Dé Luain', description: 'Grammar test for Irish, ainmlae case' },
 110+ { word: 'an Satharn', grammarForm: 'ainmlae', expected: 'Dé Sathairn', description: 'Grammar test for Irish, ainmlae case' },
 111+ ]
 112+});
Index: branches/jsgrammar/resources/Resources.php
@@ -679,6 +679,7 @@
680680 'hi' => 'resources/mediawiki.language/languages/hi.js',
681681 'hr' => 'resources/mediawiki.language/languages/hr.js',
682682 'hsb' => 'resources/mediawiki.language/languages/hsb.js',
 683+ 'hu' => 'resources/mediawiki.language/languages/hu.js',
683684 'hy' => 'resources/mediawiki.language/languages/hy.js',
684685 'ksh' => 'resources/mediawiki.language/languages/ksh.js',
685686 'ln' => 'resources/mediawiki.language/languages/ln.js',
Index: branches/jsgrammar/resources/mediawiki.language/languages/dsb.js
@@ -16,3 +16,19 @@
1717 return forms[3];
1818 }
1919 };
 20+
 21+mediaWiki.language.convertGrammar = function( word, form ) {
 22+ var grammarForms = mw.language.data[ 'dsb' ].get( 'grammarForms' );
 23+ if ( grammarForms && grammarForms[form] ) {
 24+ return grammarForms[form][word] ;
 25+ }
 26+ switch ( form ) {
 27+ case 'instrumental': // instrumental
 28+ word = 'z ' + word;
 29+ break;
 30+ case 'lokatiw': // lokatiw
 31+ word = 'wo ' + word;
 32+ break;
 33+ }
 34+ return word;
 35+};
Index: branches/jsgrammar/resources/mediawiki.language/languages/hu.js
@@ -0,0 +1,23 @@
 2+/**
 3+ * Hungarian language functions
 4+ * @author Santhosh Thottingal
 5+ */
 6+
 7+mediaWiki.language.convertGrammar = function( word, form ) {
 8+ var grammarForms = mw.language.data[ 'hu' ].get( 'grammarForms' );
 9+ if ( grammarForms && grammarForms[form] ) {
 10+ return grammarForms[form][word] ;
 11+ }
 12+ switch ( form ) {
 13+ case 'rol':
 14+ word += 'ról';
 15+ break;
 16+ case 'ba':
 17+ word += 'ba';
 18+ break;
 19+ case 'k':
 20+ word += 'k';
 21+ break;
 22+ }
 23+ return word;
 24+};
Property changes on: branches/jsgrammar/resources/mediawiki.language/languages/hu.js
___________________________________________________________________
Added: svn:eol-style
125 + native
Index: branches/jsgrammar/resources/mediawiki.language/languages/ga.js
@@ -12,3 +12,38 @@
1313 }
1414 return forms[2];
1515 };
 16+
 17+
 18+mediaWiki.language.convertGrammar = function( word, form ) {
 19+ var grammarForms = mw.language.data[ 'ga' ].get( 'grammarForms' );
 20+ if ( grammarForms && grammarForms[form] ) {
 21+ return grammarForms[form][word] ;
 22+ }
 23+ switch ( form ) {
 24+ case 'ainmlae':
 25+ switch ( word ) {
 26+ case 'an Domhnach':
 27+ word = 'Dé Domhnaigh';
 28+ break;
 29+ case 'an Luan':
 30+ word = 'Dé Luain';
 31+ break;
 32+ case 'an Mháirt':
 33+ word = 'Dé Mháirt';
 34+ break;
 35+ case 'an Chéadaoin':
 36+ word = 'Dé Chéadaoin';
 37+ break;
 38+ case 'an Déardaoin':
 39+ word = 'Déardaoin';
 40+ break;
 41+ case 'an Aoine':
 42+ word = 'Dé hAoine';
 43+ break;
 44+ case 'an Satharn':
 45+ word = 'Dé Sathairn';
 46+ break;
 47+ }
 48+ }
 49+ return word;
 50+};
Index: branches/jsgrammar/resources/mediawiki.language/languages/fi.js
@@ -10,7 +10,7 @@
1111 }
1212
1313 // vowel harmony flag
14 - aou = word.match( /[aou][^äöy]*$/i );
 14+ var aou = word.match( /[aou][^äöy]*$/i );
1515
1616 if ( word.match( /wiki$/i ) ) {
1717 aou = false;

Sign-offs

UserFlagDate
Nikerabbitinspected07:42, 20 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r111912Ukrainian grammar rules ported to js with qunit testcases...santhosh06:10, 20 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111744Russian and Finnish grammar rules in javascript and qunit test cases.santhosh12:13, 17 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:42, 20 February 2012

Those trailing commas in arrays may upset some browsers.

Status & tagging log