MediaWiki
REL1_20
|
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 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) { 00087 $hyphen = '-'; 00088 } 00089 00090 switch ( $case ) { 00091 case 'genitive': $ending = $hyphen . $jot . 'ы'; break; 00092 case 'dative': $ending = $hyphen . $jot . 'æн'; break; 00093 case 'allative': $ending = $hyphen . $end_allative; break; 00094 case 'ablative': 00095 if ( $jot == 'й' ) { 00096 $ending = $hyphen . $jot . 'æ'; break; 00097 } 00098 else { 00099 $ending = $hyphen . $jot . 'æй'; break; 00100 } 00101 case 'inessive': break; 00102 case 'superessive': $ending = $hyphen . $jot . 'ыл'; break; 00103 case 'equative': $ending = $hyphen . $jot . 'ау'; break; 00104 case 'comitative': $ending = $hyphen . 'имæ'; break; 00105 } 00106 return $word . $ending; 00107 } 00108 }