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