Added result properties to action=paraminfo
[lhc/web/wiklou.git] / languages / classes / LanguageOs.php
1 <?php
2
3 /** Ossetian (Ирон)
4 *
5 * @author Soslan Khubulov
6 *
7 * @ingroup Language
8 */
9 class LanguageOs extends Language {
10
11 /**
12 * Convert from the nominative form of a noun to other cases
13 * Invoked with {{grammar:case|word}}
14 *
15 * Depending on word there are four different ways of converting to other cases.
16 * 1) Word consist of not cyrillic letters or is an abbreviation.
17 * Then result word is: word + hyphen + case ending.
18 *
19 * 2) Word consist of cyrillic letters.
20 * 2.1) Word is in plural.
21 * Then result word is: word - last letter + case ending. Ending of allative case here is 'æм'.
22 *
23 * 2.2) Word is in singular.
24 * 2.2.1) Word ends on consonant.
25 * Then result word is: word + case ending.
26 *
27 * 2.2.2) Word ends on vowel.
28 * Then result word is: word + 'й' + case ending for cases != allative or comitative
29 * and word + case ending for allative or comitative. Ending of allative case here is 'æ'.
30 *
31 * @param $word string
32 * @param $case string
33 * @return string
34 */
35 function convertGrammar( $word, $case ) {
36 global $wgGrammarForms;
37 if ( isset( $wgGrammarForms['os'][$case][$word] ) ) {
38 return $wgGrammarForms['os'][$case][$word];
39 }
40 # Ending for allative case
41 $end_allative = 'мæ';
42 # Variable for 'j' beetwen vowels
43 $jot = '';
44 # Variable for "-" for not Ossetic words
45 $hyphen = '';
46 # Variable for ending
47 $ending = '';
48
49
50 # CHecking if the $word is in plural form
51 if ( preg_match( '/тæ$/u', $word ) ) {
52 $word = mb_substr( $word, 0, -1 );
53 $end_allative = 'æм';
54 }
55 # Works if $word is in singular form.
56 # Checking if $word ends on one of the vowels: е, ё, и, о, ы, э, ю, я.
57 elseif ( preg_match( "/[аæеёиоыэюя]$/u", $word ) ) {
58 $jot = 'й';
59 }
60 # Checking if $word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic.
61 # Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы.
62 elseif ( preg_match( "/у$/u", $word ) ) {
63 if ( !preg_match( "/[аæеёиоыэюя]$/u", mb_substr( $word, -2, 1 ) ) )
64 $jot = 'й';
65 } elseif ( !preg_match( "/[бвгджзйклмнопрстфхцчшщьъ]$/u", $word ) ) {
66 $hyphen = '-';
67 }
68
69 switch ( $case ) {
70 case 'genitive': $ending = $hyphen . $jot . 'ы'; break;
71 case 'dative': $ending = $hyphen . $jot . 'æн'; break;
72 case 'allative': $ending = $hyphen . $end_allative; break;
73 case 'ablative':
74 if ( $jot == 'й' ) {
75 $ending = $hyphen . $jot . 'æ'; break;
76 }
77 else {
78 $ending = $hyphen . $jot . 'æй'; break;
79 }
80 case 'inessive': break;
81 case 'superessive': $ending = $hyphen . $jot . 'ыл'; break;
82 case 'equative': $ending = $hyphen . $jot . 'ау'; break;
83 case 'comitative': $ending = $hyphen . 'имæ'; break;
84 }
85 return $word . $ending;
86 }
87 }