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