MediaWiki
REL1_22
|
00001 <?php 00030 class LanguageOs extends Language { 00031 00056 function convertGrammar( $word, $case ) { 00057 global $wgGrammarForms; 00058 if ( isset( $wgGrammarForms['os'][$case][$word] ) ) { 00059 return $wgGrammarForms['os'][$case][$word]; 00060 } 00061 # Ending for allative case 00062 $end_allative = 'мæ'; 00063 # Variable for 'j' beetwen vowels 00064 $jot = ''; 00065 # Variable for "-" for not Ossetic words 00066 $hyphen = ''; 00067 # Variable for ending 00068 $ending = ''; 00069 00070 00071 # CHecking if the $word is in plural form 00072 if ( preg_match( '/тæ$/u', $word ) ) { 00073 $word = mb_substr( $word, 0, -1 ); 00074 $end_allative = 'æм'; 00075 } 00076 # Works if $word is in singular form. 00077 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я. 00078 elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) { 00079 $jot = 'й'; 00080 } 00081 # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic. 00082 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы. 00083 elseif ( preg_match( "/у$/u", $word ) ) { 00084 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) { 00085 $jot = 'й'; 00086 } 00087 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) { 00088 $hyphen = '-'; 00089 } 00090 00091 switch ( $case ) { 00092 case 'genitive': 00093 $ending = $hyphen . $jot . 'ы'; 00094 break; 00095 case 'dative': 00096 $ending = $hyphen . $jot . 'æн'; 00097 break; 00098 case 'allative': 00099 $ending = $hyphen . $end_allative; 00100 break; 00101 case 'ablative': 00102 if ( $jot == 'й' ) { 00103 $ending = $hyphen . $jot . 'æ'; 00104 } else { 00105 $ending = $hyphen . $jot . 'æй'; 00106 } 00107 break; 00108 case 'inessive': 00109 break; 00110 case 'superessive': 00111 $ending = $hyphen . $jot . 'ыл'; 00112 break; 00113 case 'equative': 00114 $ending = $hyphen . $jot . 'ау'; 00115 break; 00116 case 'comitative': 00117 $ending = $hyphen . 'имæ'; 00118 break; 00119 } 00120 return $word . $ending; 00121 } 00122 }