3 * Ripuarian (Ripoarėsh) specific code.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @author Purodha Blissenbach
26 * Ripuarian (Ripoarėsh)
30 class LanguageKsh
extends Language
{
31 private static $familygender = array(
32 // Do not add male wiki families, since that's the default.
33 // No need add neuter wikis having names ending in -wiki.
42 'translatewiki.net' => 'n',
46 * Convert from the nominative form of a noun to other cases.
47 * Invoked with {{GRAMMAR:case|word}} inside messages.
49 * case is a sequence of words, each of which is case insensitive.
50 * Between words, there must be at least one space character.
51 * Only the 1st character of each word is considered.
52 * Word order is irrelevant.
54 * Possible values specifying the grammatical case are:
58 * 4, Accusative, -omitted-
60 * Possible values specifying the article type are:
61 * Betoont focussed or stressed article
62 * -omitted- unstressed or unfocussed article
64 * Possible values for the type of genitive are:
65 * Sing, Iehr prepositioned genitive = possessive dative
66 * Vun, Fon, -omitted- postpositioned genitive
67 * = preposition "vun" with dative
69 * Values of case overrides & prepositions, in the order of preceedence:
70 * Sing, Iehr possessive dative = prepositioned genitive
71 * Vun, Fon preposition "vun" with dative
72 * = postpositioned genitive
73 * En, em preposition "en" with dative
75 * Values for object gender specifiers of the possessive dative, or
76 * prepositioned genitive, evaluated with "Sing, Iehr" of above only:
77 * Male a singular male object follows
78 * -omitted- a non-male or plural object follows
80 * We currently handle definite articles of the singular only.
81 * There is a full set of test cases at:
82 * http://translatewiki.net/wiki/Portal:Ksh#GRAMMAR_Pr%C3%B6%C3%B6fe
83 * Contents of the leftmost table column can be copied and pasted as
91 function convertGrammar( $word, $case ) {
92 $lord = strtolower( $word );
93 $gender = 'm'; // Nuutnaarel // default
94 if ( preg_match ( '/wiki$/', $lord ) ) {
95 $gender = 'n'; // Dat xyz-wiki
97 if ( isset( self
::$familygender[$lord] ) ) {
98 $gender = self
::$familygender[$lord];
100 $case = ' ' . strtolower( $case );
101 if ( preg_match( '/ [is]/', $case ) ) {
102 # däm WikiMaatplaz singe, dä Wikipeedija iere, däm Wikiwööterbooch singe
103 # dem/em WikiMaatplaz singe, de Wikipeedija iere, dem/em Wikiwööterbooch singe
104 # däm WikiMaatplaz sing, dä Wikipeedija ier, däm Wikiwööterbooch sing
105 # dem/em WikiMaatplaz sing, de Wikipeedija ier, dem/em Wikiwööterbooch sing
106 $word = ( preg_match( '/ b/', $case )
107 ?
( $gender == 'f' ?
'dä' : 'däm' )
108 : ( $gender == 'f' ?
'de' : 'dem' )
109 ) . ' ' . $word . ' ' .
110 ( $gender == 'f' ?
'ier' : 'sing' ) .
111 ( preg_match( '/ m/', $case ) ?
'e' : ''
113 } elseif ( preg_match( '/ e/', $case ) ) {
114 # en dämm WikiMaatPlaz, en dä Wikipeedija, en dämm Wikiwööterbooch
115 # em WikiMaatplaz, en de Wikipeedija, em Wikiwööterbooch
116 if ( preg_match( '/ b/', $case ) ) {
117 $word = 'en ' . ( $gender == 'f' ?
'dä' : 'däm' ) . ' ' . $word;
119 $word = ( $gender == 'f' ?
'en de' : 'em' ) . ' ' . $word;
121 } elseif ( preg_match( '/ [fv]/', $case ) ||
preg_match( '/ [2jg]/', $case ) ) {
122 # vun däm WikiMaatplaz, vun dä Wikipeedija, vun däm Wikiwööterbooch
123 # vum WikiMaatplaz, vun de Wikipeedija, vum Wikiwööterbooch
124 if ( preg_match( '/ b/', $case ) ) {
125 $word = 'vun ' . ( $gender == 'f' ?
'dä' : 'däm' ) . ' ' . $word;
127 $word = ( $gender == 'f' ?
'vun de' : 'vum' ) . ' ' . $word;
129 } elseif ( preg_match( '/ [3d]/', $case ) ) {
130 # dämm WikiMaatPlaz, dä Wikipeedija, dämm Wikiwööterbooch
131 # dem/em WikiMaatplaz, de Wikipeedija, dem/em Wikiwööterbooch
132 if ( preg_match( '/ b/', $case ) ) {
133 $word = ( $gender == 'f' ?
'dää' : 'dämm' ) . ' ' . $word;
135 $word = ( $gender == 'f' ?
'de' : 'dem' ) . ' ' . $word;
138 # dä WikiMaatPlaz, di Wikipeedija, dat Wikiwööterbooch
139 # der WikiMaatplaz, de Wikipeedija, et Wikiwööterbooch
140 if ( preg_match( '/ b/', $case ) ) {
163 $word = $lord . ' ' . $word;
169 * Avoid grouping whole numbers between 0 to 9999
175 public function commafy( $_ ) {
176 if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
177 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
184 * Handle cases of (1, other, 0) or (1, other)
187 * @param array $forms
191 function convertPlural( $count, $forms ) {
192 $forms = $this->handleExplicitPluralForms( $count, $forms );
193 if ( is_string( $forms ) ) {
196 if ( !count( $forms ) ) {
199 $forms = $this->preConvertPlural( $forms, 3 );
203 } elseif ( $count == 0 ) {