r111919 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111918‎ | r111919 | r111920 >
Date:10:10, 20 February 2012
Author:santhosh
Status:ok
Tags:i18nreview 
Comment:
Port grammar rules to js for os, sl with qunit tests
Fix an encoding issue in for uk reported in r111912
Modified paths:
  • /branches/jsgrammar/resources/Resources.php (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/os.js (added) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/sl.js (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/uk.js (modified) (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
@@ -122,3 +122,25 @@
123123 { word: 'Вікіпедія', grammarForm: 'accusative', expected: 'Вікіпедію', description: 'Grammar test for Ukrainian, accusative case' }
124124 ]
125125 });
 126+
 127+
 128+mw.language.grammartest({
 129+ language: 'sl',
 130+ test: [
 131+ { word: 'word', grammarForm: 'orodnik', expected: 'z word', description: 'Grammar test for Slovenian, orodnik case' },
 132+ { word: 'word', grammarForm: 'mestnik', expected: 'o word', description: 'Grammar test for Slovenian, mestnik case' }
 133+ ]
 134+});
 135+
 136+mw.language.grammartest({
 137+ language: 'os',
 138+ test: [
 139+ { word: 'бæстæ', grammarForm: 'genitive', expected: 'бæсты', description: 'Grammar test for Ossetian, genitive case' },
 140+ { word: 'бæстæ', grammarForm: 'allative', expected: 'бæстæм', description: 'Grammar test for Ossetian, allative case' },
 141+ { word: 'Тигр', grammarForm: 'dative', expected: 'Тигрæн', description: 'Grammar test for Ossetian, dative case' },
 142+ { word: 'цъити', grammarForm: 'dative', expected: 'цъитийæн', description: 'Grammar test for Ossetian, dative case' },
 143+ { word: 'лæппу', grammarForm: 'genitive', expected: 'лæппуйы', description: 'Grammar test for Ossetian, genitive case' },
 144+ { word: '2011', grammarForm: 'equative', expected: '2011-ау', description: 'Grammar test for Ossetian, equative case' }
 145+ ]
 146+});
 147+
Index: branches/jsgrammar/resources/Resources.php
@@ -691,6 +691,7 @@
692692 'mt' => 'resources/mediawiki.language/languages/mt.js',
693693 'nl' => 'resources/mediawiki.language/languages/nl.js',
694694 'nso' => 'resources/mediawiki.language/languages/nso.js',
 695+ 'os' => 'resources/mediawiki.language/languages/os.js',
695696 'pl' => 'resources/mediawiki.language/languages/pl.js',
696697 'pt' => 'resources/mediawiki.language/languages/pt.js',
697698 'pt-br' => 'resources/mediawiki.language/languages/pt-br.js',
Index: branches/jsgrammar/resources/mediawiki.language/languages/uk.js
@@ -1,5 +1,5 @@
22 /**
3 - * Ukrainian (УкраїМська) language functions
 3+ * Ukrainian (Українська) language functions
44 */
55
66 mediaWiki.language.convertPlural = function( count, forms ) {
Index: branches/jsgrammar/resources/mediawiki.language/languages/os.js
@@ -0,0 +1,69 @@
 2+/**
 3+ * Ossetian (Ирон) language functions
 4+ * @author Santhosh Thottingal
 5+ */
 6+
 7+
 8+mediaWiki.language.convertGrammar = function( word, form ) {
 9+ var grammarForms = mw.language.data[ 'os' ].get( 'grammarForms' );
 10+ if ( grammarForms && grammarForms[form] ) {
 11+ return grammarForms[form][word] ;
 12+ }
 13+ // Ending for allative case
 14+ var end_allative = 'мæ';
 15+ // Variable for 'j' beetwen vowels
 16+ var jot = '';
 17+ // Variable for "-" for not Ossetic words
 18+ var hyphen = '';
 19+ // Variable for ending
 20+ var ending = '';
 21+ // Checking if the $word is in plural form
 22+ if ( word.match( /тæ$/i ) ) {
 23+ word = word.substring( 0, word.length - 1 );
 24+ end_allative = 'æм';
 25+ }
 26+ // Works if word is in singular form.
 27+ // Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
 28+ else if ( word.match( /[аæеёиоыэюя]$/i ) ) {
 29+ jot = 'й';
 30+ }
 31+ // Checking if word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
 32+ // Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
 33+ else if ( word.match( /у$/i ) ) {
 34+ if ( ! word.substring( word.length-2, word.length-1 ).match( /[аæеёиоыэюя]$/i ) ) {
 35+ jot = 'й';
 36+ }
 37+ } else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) {
 38+ hyphen = '-';
 39+ }
 40+
 41+ switch ( form ) {
 42+ case 'genitive':
 43+ ending = hyphen + jot + 'ы';
 44+ break;
 45+ case 'dative':
 46+ ending = hyphen + jot + 'æн';
 47+ break;
 48+ case 'allative':
 49+ ending = hyphen + end_allative;
 50+ break;
 51+ case 'ablative':
 52+ if ( jot == 'й' ) {
 53+ ending = hyphen + jot + 'æ';
 54+ }
 55+ else {
 56+ ending = hyphen + jot + 'æй';
 57+ }
 58+ break;
 59+ case 'superessive':
 60+ ending = hyphen + jot + 'ыл';
 61+ break;
 62+ case 'equative':
 63+ ending = hyphen + jot + 'ау';
 64+ break;
 65+ case 'comitative':
 66+ ending = hyphen + 'имæ';
 67+ break;
 68+ }
 69+ return word + ending;
 70+};
Property changes on: branches/jsgrammar/resources/mediawiki.language/languages/os.js
___________________________________________________________________
Added: svn:eol-style
171 + native
Index: branches/jsgrammar/resources/mediawiki.language/languages/sl.js
@@ -18,3 +18,19 @@
1919 }
2020 return forms[4];
2121 };
 22+
 23+mediaWiki.language.convertGrammar = function( word, form ) {
 24+ var grammarForms = mw.language.data[ 'sl' ].get( 'grammarForms' );
 25+ if ( grammarForms && grammarForms[form] ) {
 26+ return grammarForms[form][word] ;
 27+ }
 28+ switch ( form ) {
 29+ case 'mestnik': // locative
 30+ word = 'o ' + word;
 31+ break;
 32+ case 'orodnik': // instrumental
 33+ word = 'z ' + word;
 34+ break;
 35+ }
 36+ return word;
 37+};

Sign-offs

UserFlagDate
Nikerabbitinspected11:54, 20 February 2012

Past revisions this follows-up on

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

Status & tagging log