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
71 # CHecking if the $word is in plural form
72 if ( preg_match( '/тæ$/u', $word ) ) {
73 $word = mb_substr( $word, 0, -1 );
76 # Works if $word is in singular form.
77 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
78 elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
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 ) ) ) {
87 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
93 $ending = $hyphen . $jot . 'ы';
96 $ending = $hyphen . $jot . 'æн';
99 $ending = $hyphen . $end_allative;
103 $ending = $hyphen . $jot . 'æ';
105 $ending = $hyphen . $jot . 'æй';
111 $ending = $hyphen . $jot . 'ыл';
114 $ending = $hyphen . $jot . 'ау';
117 $ending = $hyphen . 'имæ';
120 return $word . $ending;