MediaWiki
REL1_19
|
00001 <?php 00002 00009 class LanguageOs extends Language { 00010 00035 function convertGrammar( $word, $case ) { 00036 global $wgGrammarForms; 00037 if ( isset( $wgGrammarForms['os'][$case][$word] ) ) { 00038 return $wgGrammarForms['os'][$case][$word]; 00039 } 00040 # Ending for allative case 00041 $end_allative = 'мæ'; 00042 # Variable for 'j' beetwen vowels 00043 $jot = ''; 00044 # Variable for "-" for not Ossetic words 00045 $hyphen = ''; 00046 # Variable for ending 00047 $ending = ''; 00048 00049 00050 # CHecking if the $word is in plural form 00051 if ( preg_match( '/тæ$/u', $word ) ) { 00052 $word = mb_substr( $word, 0, -1 ); 00053 $end_allative = 'æм'; 00054 } 00055 # Works if $word is in singular form. 00056 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я. 00057 elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) { 00058 $jot = 'й'; 00059 } 00060 # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic. 00061 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы. 00062 elseif ( preg_match( "/у$/u", $word ) ) { 00063 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) 00064 $jot = 'й'; 00065 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) { 00066 $hyphen = '-'; 00067 } 00068 00069 switch ( $case ) { 00070 case 'genitive': $ending = $hyphen . $jot . 'ы'; break; 00071 case 'dative': $ending = $hyphen . $jot . 'æн'; break; 00072 case 'allative': $ending = $hyphen . $end_allative; break; 00073 case 'ablative': 00074 if ( $jot == 'й' ) { 00075 $ending = $hyphen . $jot . 'æ'; break; 00076 } 00077 else { 00078 $ending = $hyphen . $jot . 'æй'; break; 00079 } 00080 case 'inessive': break; 00081 case 'superessive': $ending = $hyphen . $jot . 'ыл'; break; 00082 case 'equative': $ending = $hyphen . $jot . 'ау'; break; 00083 case 'comitative': $ending = $hyphen . 'имæ'; break; 00084 } 00085 return $word . $ending; 00086 } 00087 }