Revert r96824: causes fatal errors when search query doesn't happen to be a valid...
[lhc/web/wiklou.git] / languages / classes / LanguageCu.php
1 <?php
2
3 /** Old Church Slavonic (Ѩзыкъ словѣньскъ)
4 *
5 * @ingroup Language
6 */
7 class LanguageCu extends Language {
8
9 /**
10 * Convert from the nominative form of a noun to some other case
11 * Invoked with {{grammar:case|word}}
12 *
13 * @param $word string
14 * @param $case string
15 * @return string
16 */
17 function convertGrammar( $word, $case ) {
18 global $wgGrammarForms;
19 if ( isset( $wgGrammarForms['сu'][$case][$word] ) ) {
20 return $wgGrammarForms['сu'][$case][$word];
21 }
22
23 # These rules are not perfect, but they are currently only used for site names so it doesn't
24 # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
25
26 # join and array_slice instead mb_substr
27 $ar = array();
28 preg_match_all( '/./us', $word, $ar );
29 if ( !preg_match( "/[a-zA-Z_]/us", $word ) )
30 switch ( $case ) {
31 case 'genitive': # родительный падеж
32 if ( ( join( '', array_slice( $ar[0], -4 ) ) == 'вики' ) || ( join( '', array_slice( $ar[0], -4 ) ) == 'Вики' ) )
33 { }
34 elseif ( join( '', array_slice( $ar[0], -2 ) ) == 'ї' )
35 $word = join( '', array_slice( $ar[0], 0, -2 ) ) . 'їѩ';
36 break;
37 case 'accusative': # винительный падеж
38 # stub
39 break;
40 }
41 return $word;
42 }
43
44 /**
45 * @param $count int
46 * @param $forms array
47 * @return string
48 */
49 function convertPlural( $count, $forms ) {
50 if ( !count( $forms ) ) { return ''; }
51 $forms = $this->preConvertPlural( $forms, 4 );
52
53 switch ( $count % 10 ) {
54 case 1: return $forms[0];
55 case 2: return $forms[1];
56 case 3:
57 case 4: return $forms[2];
58 default: return $forms[3];
59 }
60 }
61 }