MediaWiki REL1_37
LanguageOs.php
Go to the documentation of this file.
1<?php
30class LanguageOs extends Language {
31
56 public function convertGrammar( $word, $case ) {
57 global $wgGrammarForms;
58 if ( isset( $wgGrammarForms['os'][$case][$word] ) ) {
59 return $wgGrammarForms['os'][$case][$word];
60 }
61 # Ending for allative case
62 $end_allative = 'мæ';
63 # Variable for 'j' beetwen vowels
64 $jot = '';
65 # Variable for "-" for not Ossetic words
66 $hyphen = '';
67 # Variable for ending
68 $ending = '';
69
70 # CHecking if the $word is in plural form
71 if ( preg_match( '/тæ$/u', $word ) ) {
72 $word = mb_substr( $word, 0, -1 );
73 $end_allative = 'æм';
74 } elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
75 # Works if $word is in singular form.
76 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
77 $jot = 'й';
78 } elseif ( preg_match( "/у$/u", $word ) ) {
79 # Checking if $word ends on 'у'. 'У'
80 # can be either consonant 'W' or vowel 'U' in Cyrillic Ossetic.
81 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
82 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) {
83 $jot = 'й';
84 }
85 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
86 $hyphen = '-';
87 }
88
89 switch ( $case ) {
90 case 'genitive':
91 $ending = $hyphen . $jot . 'ы';
92 break;
93 case 'dative':
94 $ending = $hyphen . $jot . 'æн';
95 break;
96 case 'allative':
97 $ending = $hyphen . $end_allative;
98 break;
99 case 'ablative':
100 if ( $jot == 'й' ) {
101 $ending = $hyphen . $jot . 'æ';
102 } else {
103 $ending = $hyphen . $jot . 'æй';
104 }
105 break;
106 case 'inessive':
107 break;
108 case 'superessive':
109 $ending = $hyphen . $jot . 'ыл';
110 break;
111 case 'equative':
112 $ending = $hyphen . $jot . 'ау';
113 break;
114 case 'comitative':
115 $ending = $hyphen . 'имæ';
116 break;
117 }
118 return $word . $ending;
119 }
120}
$wgGrammarForms
Some languages need different word forms, usually for different cases.
Ossetian (Ирон)
convertGrammar( $word, $case)
Convert from the nominative form of a noun to other cases Invoked with {{grammar:case|word}}.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition Language.php:42