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
21 * @author Soslan Khubulov
30 class LanguageOs
extends Language
{
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 'æ'.
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
63 # Variable for 'j' beetwen vowels
65 # Variable for "-" for not Ossetic words
70 # CHecking if the $word is in plural form
71 if ( preg_match( '/тæ$/u', $word ) ) {
72 $word = mb_substr( $word, 0, -1 );
75 # Works if $word is in singular form.
76 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
77 elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
80 # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
81 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
82 elseif ( preg_match( "/у$/u", $word ) ) {
83 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) ) {
86 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
92 $ending = $hyphen . $jot . 'ы';
95 $ending = $hyphen . $jot . 'æн';
98 $ending = $hyphen . $end_allative;
102 $ending = $hyphen . $jot . 'æ';
104 $ending = $hyphen . $jot . 'æй';
110 $ending = $hyphen . $jot . 'ыл';
113 $ending = $hyphen . $jot . 'ау';
116 $ending = $hyphen . 'имæ';
119 return $word . $ending;