r111923 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111922‎ | r111923 | r111924 >
Date:11:36, 20 February 2012
Author:santhosh
Status:ok (Comments)
Tags:i18nreview 
Comment:
Port convertGrammar method of Lating to js with qunit tests.
Modified paths:
  • /branches/jsgrammar/resources/Resources.php (modified) (history)
  • /branches/jsgrammar/resources/mediawiki.language/languages/la.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
@@ -144,3 +144,12 @@
145145 ]
146146 });
147147
 148+mw.language.grammartest({
 149+ language: 'la',
 150+ test: [
 151+ { word: 'Translatio', grammarForm: 'genitive', expected: 'Translationis', description: 'Grammar test for Latin, genitive case' },
 152+ { word: 'Translatio', grammarForm: 'accusative', expected: 'Translationem', description: 'Grammar test for Latin, accusative case' },
 153+ { word: 'Translatio', grammarForm: 'ablative', expected: 'Translatione', description: 'Grammar test for Latin, ablative case' }
 154+ ]
 155+});
 156+
Index: branches/jsgrammar/resources/Resources.php
@@ -682,6 +682,7 @@
683683 'hu' => 'resources/mediawiki.language/languages/hu.js',
684684 'hy' => 'resources/mediawiki.language/languages/hy.js',
685685 'ksh' => 'resources/mediawiki.language/languages/ksh.js',
 686+ 'la' => 'resources/mediawiki.language/languages/la.js',
686687 'ln' => 'resources/mediawiki.language/languages/ln.js',
687688 'lt' => 'resources/mediawiki.language/languages/lt.js',
688689 'lv' => 'resources/mediawiki.language/languages/lv.js',
Index: branches/jsgrammar/resources/mediawiki.language/languages/la.js
@@ -0,0 +1,50 @@
 2+/**
 3+ * Latin (lingua Latina) language functions
 4+ * @author Santhosh Thottingal
 5+ */
 6+
 7+mediaWiki.language.convertGrammar = function( word, form ) {
 8+ var grammarForms = mw.language.data[ 'la' ].get( 'grammarForms' );
 9+ if ( grammarForms && grammarForms[form] ) {
 10+ return grammarForms[form][word] ;
 11+ }
 12+ switch ( form ) {
 13+ case 'genitive':
 14+ // only a few declensions, and even for those mostly the singular only
 15+ word = word.replace( /u[ms]$/i, 'i' ); // 2nd declension singular
 16+ word = word.replace( /ommunia$/i, 'ommunium' ); // 3rd declension neuter plural (partly)
 17+ word = word.replace( /a$/i, 'ae' ); // 1st declension singular
 18+ word = word.replace( /libri$/i,'librorum' ); // 2nd declension plural (partly)
 19+ word = word.replace( /nuntii$/i, 'nuntiorum' ); // 2nd declension plural (partly)
 20+ word = word.replace( /tio$/i,'tionis' ); // 3rd declension singular (partly)
 21+ word = word.replace( /ns$/i, 'ntis' );
 22+ word = word.replace( /as$/i, 'atis' );
 23+ word = word.replace( /es$/i ,'ei' ); // 5th declension singular
 24+ break;
 25+ case 'accusative':
 26+ // only a few declensions, and even for those mostly the singular only
 27+ word = word.replace( /u[ms]$/i, 'um' ); // 2nd declension singular
 28+ word = word.replace( /ommunia$/i, 'am' ); // 3rd declension neuter plural (partly)
 29+ word = word.replace( /a$/i, 'ommunia' ); // 1st declension singular
 30+ word = word.replace( /libri$/i,'libros' ); // 2nd declension plural (partly)
 31+ word = word.replace( /nuntii$/i, 'nuntios' );// 2nd declension plural (partly)
 32+ word = word.replace( /tio$/i,'tionem' ); // 3rd declension singular (partly)
 33+ word = word.replace( /ns$/i, 'ntem' );
 34+ word = word.replace( /as$/i, 'atem');
 35+ word = word.replace( /es$/i ,'em' ); // 5th declension singular
 36+ break;
 37+ case 'ablative':
 38+ // only a few declensions, and even for those mostly the singular only
 39+ word = word.replace( /u[ms]$/i, 'o' ); // 2nd declension singular
 40+ word = word.replace( /ommunia$/i, 'ommunibus' ); // 3rd declension neuter plural (partly)
 41+ word = word.replace( /a$/i, 'a' ); // 1st declension singular
 42+ word = word.replace( /libri$/i,'libris' ); // 2nd declension plural (partly)
 43+ word = word.replace( /nuntii$/i, 'nuntiis' ); // 2nd declension plural (partly)
 44+ word = word.replace( /tio$/i,'tione' ); // 3rd declension singular (partly)
 45+ word = word.replace( /ns$/i, 'nte' );
 46+ word = word.replace( /as$/i, 'ate');
 47+ word = word.replace( /es$/i ,'e' ); // 5th declension singular
 48+ break;
 49+ }
 50+ return word;
 51+};
Property changes on: branches/jsgrammar/resources/mediawiki.language/languages/la.js
___________________________________________________________________
Added: svn:eol-style
152 + native

Comments

#Comment by Santhosh.thottingal (talk | contribs)   11:38, 20 February 2012

s/Lating/Latin in commit message.

#Comment by Nikerabbit (talk | contribs)   11:52, 20 February 2012

Are you planning to add more test words?

Status & tagging log