MediaWiki  REL1_24
LanguageOs.php
Go to the documentation of this file.
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         # CHecking if the $word is in plural form
00071         if ( preg_match( '/тæ$/u', $word ) ) {
00072             $word = mb_substr( $word, 0, -1 );
00073             $end_allative = 'æм';
00074         }
00075         # Works if $word is in singular form.
00076         # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
00077         elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
00078             $jot = 'й';
00079         }
00080         # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
00081         # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
00082         elseif ( preg_match( "/у$/u", $word ) ) {
00083             if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) {
00084                 $jot = 'й';
00085             }
00086         } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
00087             $hyphen = '-';
00088         }
00089 
00090         switch ( $case ) {
00091             case 'genitive':
00092                 $ending = $hyphen . $jot . 'ы';
00093                 break;
00094             case 'dative':
00095                 $ending = $hyphen . $jot . 'æн';
00096                 break;
00097             case 'allative':
00098                 $ending = $hyphen . $end_allative;
00099                 break;
00100             case 'ablative':
00101                 if ( $jot == 'й' ) {
00102                     $ending = $hyphen . $jot . 'æ';
00103                 } else {
00104                     $ending = $hyphen . $jot . 'æй';
00105                 }
00106                 break;
00107             case 'inessive':
00108                 break;
00109             case 'superessive':
00110                 $ending = $hyphen . $jot . 'ыл';
00111                 break;
00112             case 'equative':
00113                 $ending = $hyphen . $jot . 'ау';
00114                 break;
00115             case 'comitative':
00116                 $ending = $hyphen . 'имæ';
00117                 break;
00118         }
00119         return $word . $ending;
00120     }
00121 }