Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / languages / classes / LanguageOs.php
blobd374c859c2a7f188e7c0ce2a0532db9e5e4a3ce1
1 <?php
2 /**
3 * Ossetian (Ирон) specific code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @author Soslan Khubulov
22 * @ingroup Language
25 /**
26 * Ossetian (Ирон)
28 * @ingroup Language
30 class LanguageOs extends Language {
32 /**
33 * Convert from the nominative form of a noun to other cases
34 * Invoked with {{grammar:case|word}}
36 * Depending on word there are four different ways of converting to other cases.
37 * 1) Word consist of not cyrillic letters or is an abbreviation.
38 * Then result word is: word + hyphen + case ending.
40 * 2) Word consist of cyrillic letters.
41 * 2.1) Word is in plural.
42 * Then result word is: word - last letter + case ending. Ending of allative case here is 'æм'.
44 * 2.2) Word is in singular.
45 * 2.2.1) Word ends on consonant.
46 * Then result word is: word + case ending.
48 * 2.2.2) Word ends on vowel.
49 * Then result word is: word + 'й' + case ending for cases != allative or comitative
50 * and word + case ending for allative or comitative. Ending of allative case here is 'æ'.
52 * @param string $word
53 * @param string $case
54 * @return string
56 function convertGrammar( $word, $case ) {
57 global $wgGrammarForms;
58 if ( isset( $wgGrammarForms['os'][$case][$word] ) ) {
59 return $wgGrammarForms['os'][$case][$word];
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 = '';
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 = 'й';
85 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
86 $hyphen = '-';
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 . 'æй';
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;
118 return $word . $ending;