MediaWiki master
LanguageOs.php
Go to the documentation of this file.
1<?php
25
31class LanguageOs extends Language {
32
57 public function convertGrammar( $word, $case ) {
58 $grammarForms =
59 MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::GrammarForms );
60 if ( isset( $grammarForms['os'][$case][$word] ) ) {
61 return $grammarForms['os'][$case][$word];
62 }
63 # Ending for the allative case
64 $end_allative = 'мæ';
65 # Variable for 'j' between vowels
66 $jot = '';
67 # Variable for "-" for not Ossetic words
68 $hyphen = '';
69 # Variable for ending
70 $ending = '';
71
72 # Checking if the $word is in plural form
73 if ( preg_match( '/тæ$/u', $word ) ) {
74 $word = mb_substr( $word, 0, -1 );
75 $end_allative = 'æм';
76 } elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
77 # Works if $word is in singular form.
78 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
79 $jot = 'й';
80 } elseif ( preg_match( "/у$/u", $word ) ) {
81 # Checking if $word ends on 'у'. 'У'
82 # can be either consonant 'W' or vowel 'U' in Cyrillic Ossetic.
83 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
84 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) {
85 $jot = 'й';
86 }
87 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
88 $hyphen = '-';
89 }
90
91 switch ( $case ) {
92 case 'genitive':
93 $ending = $hyphen . $jot . 'ы';
94 break;
95
96 case 'dative':
97 $ending = $hyphen . $jot . 'æн';
98 break;
99
100 case 'allative':
101 $ending = $hyphen . $end_allative;
102 break;
103
104 case 'ablative':
105 if ( $jot == 'й' ) {
106 $ending = $hyphen . $jot . 'æ';
107 } else {
108 $ending = $hyphen . $jot . 'æй';
109 }
110 break;
111
112 case 'inessive':
113 break;
114
115 case 'superessive':
116 $ending = $hyphen . $jot . 'ыл';
117 break;
118
119 case 'equative':
120 $ending = $hyphen . $jot . 'ау';
121 break;
122
123 case 'comitative':
124 $ending = $hyphen . 'имæ';
125 break;
126 }
127 return $word . $ending;
128 }
129}
Ossetian (Ирон)
convertGrammar( $word, $case)
Convert from the nominative form of a noun to other cases Invoked with {{grammar:case|word}}.
Base class for language-specific code.
Definition Language.php:81
A class containing constants representing the names of configuration variables.
Service locator for MediaWiki core services.