3 /** Ripuarian (Ripoarėsh)
7 * @author Purodha Blissenbach
9 class LanguageKsh extends Language {
10 static $familygender = array(
11 // Do not add male wiki families, since that's the default.
12 // No need add neuter wikis having names ending in -wiki.
21 'translatewiki.net' => 'n',
24 * Convert from the nominative form of a noun to other cases.
25 * Invoked with {{GRAMMAR:case|word}} inside messages.
27 * case is a sequence of words, each of which is case insensitive.
28 * Between words, there must be at least one space character.
29 * Only the 1st character of each word is considered.
30 * Word order is irrelevant.
32 * Possible values specifying the grammatical case are:
36 * 4, Accusative, -omitted-
38 * Possible values specifying the article type are:
39 * Betoont focussed or stressed article
40 * -omitted- unstressed or unfocussed article
42 * Possible values for for the type of genitive are:
43 * Sing, Iehr prepositioned genitive = possessive dative
44 * Vun, Fon, -omitted- postpositioned genitive
45 * = preposition "vun" with dative
47 * Values of case overrides & prepositions, in the order of preceedence:
48 * Sing, Iehr possessive dative = prepositioned genitive
49 * Vun, Fon preposition "vun" with dative
50 * = postpositioned genitive
51 * En, em preposition "en" with dative
53 * Values for object gender specifiers of the possessive dative, or
54 * prepositioned genitive, evaluated with "Sing, Iehr" of above only:
55 * Male a singular male object follows
56 * -omitted- a non-male or plural object follows
58 * We currently handle definite articles of the singular only.
59 * There is a full set of test cases at:
60 * http://translatewiki.net/wiki/Portal:Ksh#GRAMMAR_Pr%C3%B6%C3%B6fe
61 * Contents of the leftmost table column can be copied and pasted as
65 function convertGrammar( $word, $case )
67 $lord = strtolower($word);
68 $gender = 'm'; // Nuutnaarel // default
69 if ( preg_match ( '/wiki$/', $lord ) )
71 $gender = 'n'; // Dat xyz-wiki
73 if ( isset( self::$familygender[$lord] ) )
75 $gender = (self::$familygender[$lord]);
77 $case = (' '.strtolower($case));
78 if ( preg_match( '/ [is]/', $case ) )
80 # däm WikiMaatplaz singe, dä Wikipeedija iere, däm Wikiwööterbooch singe
81 # dem/em WikiMaatplaz singe, de Wikipeedija iere, dem/em Wikiwööterbooch singe
82 # däm WikiMaatplaz sing, dä Wikipeedija ier, däm Wikiwööterbooch sing
83 # dem/em WikiMaatplaz sing, de Wikipeedija ier, dem/em Wikiwööterbooch sing
84 $word = ( preg_match( '/ b/', $case )
99 ( preg_match( '/ m/', $case )
104 elseif ( preg_match( '/ e/', $case ) )
106 # en dämm WikiMaatPlaz, en dä Wikipeedija, en dämm Wikiwööterbooch
107 # em WikiMaatplaz, en de Wikipeedija, em Wikiwööterbooch
108 if ( preg_match( '/ b/', $case ) )
110 $word = ('en '.($gender=='f'?'dä':'däm').' '.$word);
114 $word = (($gender=='f'?'en de':'em').' '.$word);
117 elseif ( preg_match( '/ [fv]/', $case ) || preg_match( '/ [2jg]/', $case ) )
119 # vun däm WikiMaatplaz, vun dä Wikipeedija, vun däm Wikiwööterbooch
120 # vum WikiMaatplaz, vun de Wikipeedija, vum Wikiwööterbooch
121 if ( preg_match( '/ b/', $case ) )
123 $word = ('vun '.($gender=='f'?'dä':'däm').' '.$word);
127 $word = (($gender=='f'?'vun de':'vum').' '.$word);
130 elseif ( preg_match( '/ [3d]/', $case ) )
132 # dämm WikiMaatPlaz, dä Wikipeedija, dämm Wikiwööterbooch
133 # dem/em WikiMaatplaz, de Wikipeedija, dem/em Wikiwööterbooch
134 if ( preg_match( '/ b/', $case ) )
136 $word = (($gender=='f'?'dää':'dämm').' '.$word);
140 $word = (($gender=='f'?'de':'dem').' '.$word);
145 # dä WikiMaatPlaz, di Wikipeedija, dat Wikiwööterbooch
146 # der WikiMaatplaz, de Wikipeedija, et Wikiwööterbooch
147 if ( preg_match( '/ b/', $case ) )
151 case 'm' : $lord = 'dä' ; break ;
152 case 'f' : $lord = 'di' ; break ;
153 default : $lord = 'dat' ; break ;
160 case 'm' : $lord = 'der' ; break ;
161 case 'f' : $lord = 'de' ; break ;
162 default : $lord = 'et' ; break ;
165 $word = ($lord.' '.$word);
171 * Avoid grouping whole numbers between 0 to 9999
173 public function commafy( $_ ) {
174 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
175 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
182 * Handle cases of (1, other, 0) or (1, other)
184 function convertPlural( $count, $forms ) {
185 if ( !count( $forms ) ) { return ''; }
186 $forms = $this->preConvertPlural( $forms, 3 );
190 } elseif ( $count == 0 ) {