DifferenceEngine cleanup
[mediawiki.git] / languages / classes / LanguageOs.php
blobf37e2d54cd5170e4885958ce258d26dda61bca86
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 $word string
53 * @param $case string
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 = '';
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 = 'æм';
76 # Works if $word is in singular form.
77 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
78 elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
79 $jot = 'й';
81 # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
82 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
83 elseif ( preg_match( "/у$/u", $word ) ) {
84 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) {
85 $jot = 'й';
87 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
88 $hyphen = '-';
91 switch ( $case ) {
92 case 'genitive':
93 $ending = $hyphen . $jot . 'ы';
94 break;
95 case 'dative':
96 $ending = $hyphen . $jot . 'æн';
97 break;
98 case 'allative':
99 $ending = $hyphen . $end_allative;
100 break;
101 case 'ablative':
102 if ( $jot == 'й' ) {
103 $ending = $hyphen . $jot . 'æ';
104 } else {
105 $ending = $hyphen . $jot . 'æй';
107 break;
108 case 'inessive':
109 break;
110 case 'superessive':
111 $ending = $hyphen . $jot . 'ыл';
112 break;
113 case 'equative':
114 $ending = $hyphen . $jot . 'ау';
115 break;
116 case 'comitative':
117 $ending = $hyphen . 'имæ';
118 break;
120 return $word . $ending;