Follow up r80376. Added missing file FORMAT.
[lhc/web/wiklou.git] / languages / classes / LanguageKu.php
1 <?php
2 require_once( dirname( __FILE__ ) . '/../LanguageConverter.php' );
3 require_once( dirname( __FILE__ ) . '/LanguageKu_ku.php' );
4
5 /**
6 * Kurdish converter routines
7 *
8 * @ingroup Language
9 */
10 class KuConverter extends LanguageConverter {
11 var $mArabicToLatin = array(
12 'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
13 'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
14 'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
15 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
16
17 // ک و => ku -- ist richtig
18 // و ك=> ku -- ist auch richtig
19
20 /* Doppel- und Halbvokale */
21 'ڵ' => 'll', # ll
22 'ڕ' => 'rr', # rr
23 'ا' => 'a',
24 # 'ئێ' => 'ê', # initial e
25 'ە' => 'e',
26 'ه‌' => 'e', # with one non-joiner
27 'ه‌‌' => 'e', # with two non-joiner
28 'ة' => 'e',
29 'ێ' => 'ê',
30 'ي' => 'î',
31 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
32 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
33 'ۆ' => 'o',
34 'و' => 'w',
35 'ئ' => '', # initial hemze should not be shown
36 '،' => ',',
37 'ع' => '\'', # ayn
38 '؟' => '?',
39
40 # digits
41 '٠' => '0', # &#x0660;
42 '١' => '1', # &#x0661;
43 '٢' => '2', # &#x0662;
44 '٣' => '3', # &#x0663;
45 '٤' => '4', # &#x0664;
46 '٥' => '5', # &#x0665;
47 '٦' => '6', # &#x0666;
48 '٧' => '7', # &#x0667;
49 '٨' => '8', # &#x0668;
50 '٩' => '9', # &#x0669;
51 );
52
53 var $mLatinToArabic = array(
54 'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
55 'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
56 'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
57 't' => 'ت', 'v' => 'ڤ',
58 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
59
60
61 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
62 'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
63 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
64 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
65 'Y' => 'ی', 'Z' => 'ز',
66
67 /* Doppelkonsonanten */
68 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
69 # 'rr' => 'ڕ', # selbiges für doppel-r
70
71 /* Einzelne Großbuchstaben */
72 // ' C' => 'ج',
73
74 /* Vowels */
75 'a' => 'ا',
76 'e' => 'ە',
77 'ê' => 'ێ',
78 'i' => '',
79 'î' => 'ی',
80 'o' => 'ۆ',
81 'u' => 'و',
82 'û' => 'وو',
83 'w' => 'و',
84 ',' => '،',
85 '?' => '؟',
86
87 # Try to replace the leading vowel
88 ' a' => 'ئا ',
89 ' e' => 'ئە ',
90 ' ê' => 'ئێ ',
91 ' î' => 'ئی ',
92 ' o' => 'ئۆ ',
93 ' u' => 'ئو ',
94 ' û' => 'ئوو ',
95 'A' => 'ئا',
96 'E' => 'ئە',
97 'Ê' => 'ئێ',
98 'Î' => 'ئی',
99 'O' => 'ئۆ',
100 'U' => 'ئو',
101 'Û' => 'ئوو',
102 ' A' => 'ئا ',
103 ' E' => 'ئە ',
104 ' Ê' => 'ئێ ',
105 ' Î' => 'ئی ',
106 ' O' => 'ئۆ ',
107 ' U' => 'ئو ',
108 ' Û' => 'ئوو ',
109 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu häufig, um sie als eyn zu interpretieren
110 # '\'' => 'ع',
111
112 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
113 # digits
114 '0' => '٠', # &#x0660;
115 '1' => '١', # &#x0661;
116 '2' => '٢', # &#x0662;
117 '3' => '٣', # &#x0663;
118 '4' => '٤', # &#x0664;
119 '5' => '٥', # &#x0665;
120 '6' => '٦', # &#x0666;
121 '7' => '٧', # &#x0667;
122 '8' => '٨', # &#x0668;
123 '9' => '٩', # &#x0669;
124 */
125 );
126
127 function loadDefaultTables() {
128 $this->mTables = array(
129 'ku-latn' => new ReplacementArray( $this->mArabicToLatin ),
130 'ku-arab' => new ReplacementArray( $this->mLatinToArabic ),
131 'ku' => new ReplacementArray()
132 );
133 }
134
135 /*
136 * A function wrapper:
137 * - if there is no selected variant, leave the link
138 * names as they were
139 * - do not try to find variants for usernames
140 */
141 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
142 // check for user namespace
143 if ( is_object( $nt ) ) {
144 $ns = $nt->getNamespace();
145 if ( $ns == NS_USER || $ns == NS_USER_TALK )
146 return;
147 }
148
149 $oldlink = $link;
150 parent::findVariantLink( $link, $nt, $ignoreOtherCond );
151 if ( $this->getPreferredVariant() == $this->mMainLanguageCode )
152 $link = $oldlink;
153 }
154
155 /*
156 * We want our external link captions to be converted in variants,
157 * so we return the original text instead -{$text}-, except for URLs
158 */
159 function markNoConversion( $text, $noParse = false ) {
160 if ( $noParse || preg_match( "/^https?:\/\/|ftp:\/\/|irc:\/\//", $text ) )
161 return parent::markNoConversion( $text );
162 return $text;
163 }
164
165 /*
166 * An ugly function wrapper for parsing Image titles
167 * (to prevent image name conversion)
168 */
169 function autoConvert( $text, $toVariant = false ) {
170 global $wgTitle;
171 if ( is_object( $wgTitle ) && $wgTitle->getNameSpace() == NS_FILE ) {
172 $imagename = $wgTitle->getNsText();
173 if ( preg_match( "/^$imagename:/", $text ) ) return $text;
174 }
175 return parent::autoConvert( $text, $toVariant );
176 }
177
178 /**
179 * It translates text into variant, specials:
180 * - ommiting roman numbers
181 */
182 function translate( $text, $toVariant ) {
183 /* From Kazakh interface, maybe we need it later
184 $breaks = '[^\w\x80-\xff]';
185 // regexp for roman numbers
186 $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
187 $roman = '';
188
189 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
190
191 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
192
193 $m = array_shift($matches);
194 if( !isset( $this->mTables[$toVariant] ) ) {
195 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
196 }
197 $ret = $this->mTables[$toVariant]->replace( $m[0] );
198 $mstart = $m[1]+strlen($m[0]);
199 foreach($matches as $m) {
200 $ret .= substr($text, $mstart, $m[1]-$mstart);
201 $ret .= parent::translate($m[0], $toVariant);
202 $mstart = $m[1] + strlen($m[0]);
203 }
204
205 return $ret;
206 */
207
208 if ( !isset( $this->mTables[$toVariant] ) ) {
209 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
210 }
211
212 return parent::translate( $text, $toVariant );
213 }
214 }
215
216 /**
217 * Kurdish (Kurdî / كوردی)
218 *
219 * @ingroup Language
220 */
221 class LanguageKu extends LanguageKu_ku {
222
223 function __construct() {
224 global $wgHooks;
225 parent::__construct();
226
227 $variants = array( 'ku', 'ku-arab', 'ku-latn' );
228 $variantfallbacks = array(
229 'ku' => 'ku-latn',
230 'ku-arab' => 'ku-latn',
231 'ku-latn' => 'ku-arab',
232 );
233
234 $this->mConverter = new KuConverter( $this, 'ku', $variants, $variantfallbacks );
235 $wgHooks['ArticleSaveComplete'][] = $this->mConverter;
236 }
237 }