* phpunit fixes & optimizations for oracle backend
[mediawiki.git] / languages / classes / LanguageCu.php
blobaf42d2c24e1b27251f33e98d63a340bf1bb0c126
1 <?php
3 /** Old Church Slavonic (Ѩзыкъ словѣньскъ)
5 * @ingroup Language
6 */
7 class LanguageCu extends Language {
9 /**
10 * Convert from the nominative form of a noun to some other case
11 * Invoked with {{grammar:case|word}}
13 * @param $word string
14 * @param $case string
15 * @return string
17 function convertGrammar( $word, $case ) {
18 global $wgGrammarForms;
19 if ( isset( $wgGrammarForms['сu'][$case][$word] ) ) {
20 return $wgGrammarForms['сu'][$case][$word];
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.
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;
41 return $word;
44 /**
45 * @param $count int
46 * @param $forms array
47 * @return string
49 function convertPlural( $count, $forms ) {
50 if ( !count( $forms ) ) { return ''; }
51 $forms = $this->preConvertPlural( $forms, 4 );
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];