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