3 * Kurdish 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
24 require_once __DIR__
. '/../LanguageConverter.php';
25 require_once __DIR__
. '/LanguageKu_ku.php';
28 * Kurdish converter routines
32 class KuConverter
extends LanguageConverter
{
33 public $mArabicToLatin = array(
34 'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
35 'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
36 'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
37 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
39 // ک و => ku -- ist richtig
40 // و ك=> ku -- ist auch richtig
42 /* Doppel- und Halbvokale */
46 # 'ئێ' => 'ê', # initial e
48 'ه' => 'e', # with one non-joiner
49 'ه' => 'e', # with two non-joiner
53 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
54 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
57 'ئ' => '', # initial hemze should not be shown
63 '٠' => '0', # ٠
64 '١' => '1', # ١
65 '٢' => '2', # ٢
66 '٣' => '3', # ٣
67 '٤' => '4', # ٤
68 '٥' => '5', # ٥
69 '٦' => '6', # ٦
70 '٧' => '7', # ٧
71 '٨' => '8', # ٨
72 '٩' => '9', # ٩
75 public $mLatinToArabic = array(
76 'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
77 'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
78 'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
79 't' => 'ت', 'v' => 'ڤ',
80 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
82 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
83 'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
84 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
85 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
86 'Y' => 'ی', 'Z' => 'ز',
88 /* Doppelkonsonanten */
89 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
90 # 'rr' => 'ڕ', # selbiges für doppel-r
92 /* Einzelne Großbuchstaben */
108 # Try to replace the leading vowel
130 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu
131 # häufig, um sie als eyn zu interpretieren.
134 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
136 '0' => '٠', # ٠
137 '1' => '١', # ١
138 '2' => '٢', # ٢
139 '3' => '٣', # ٣
140 '4' => '٤', # ٤
141 '5' => '٥', # ٥
142 '6' => '٦', # ٦
143 '7' => '٧', # ٧
144 '8' => '٨', # ٨
145 '9' => '٩', # ٩
149 function loadDefaultTables() {
150 $this->mTables
= array(
151 'ku-latn' => new ReplacementArray( $this->mArabicToLatin
),
152 'ku-arab' => new ReplacementArray( $this->mLatinToArabic
),
153 'ku' => new ReplacementArray()
158 * A function wrapper:
159 * - if there is no selected variant, leave the link
161 * - do not try to find variants for usernames
163 * @param string &$link
165 * @param bool $ignoreOtherCond
167 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
168 // check for user namespace
169 if ( is_object( $nt ) ) {
170 $ns = $nt->getNamespace();
171 if ( $ns == NS_USER ||
$ns == NS_USER_TALK
) {
177 parent
::findVariantLink( $link, $nt, $ignoreOtherCond );
178 if ( $this->getPreferredVariant() == $this->mMainLanguageCode
) {
184 * It translates text into variant, specials:
185 * - ommiting roman numbers
187 * @param string $text
188 * @param bool $toVariant
190 * @throws MWException
193 function translate( $text, $toVariant ) {
195 /* From Kazakh interface, maybe we need it later
196 $breaks = '[^\w\x80-\xff]';
197 // regexp for roman numbers
198 $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
201 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
203 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
205 $m = array_shift($matches);
206 if( !isset( $this->mTables[$toVariant] ) ) {
207 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
209 $ret = $this->mTables[$toVariant]->replace( $m[0] );
210 $mstart = $m[1]+strlen($m[0]);
211 foreach($matches as $m) {
212 $ret .= substr($text, $mstart, $m[1]-$mstart);
213 $ret .= parent::translate($m[0], $toVariant);
214 $mstart = $m[1] + strlen($m[0]);
220 if ( !isset( $this->mTables
[$toVariant] ) ) {
221 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables
) ) );
224 return parent
::translate( $text, $toVariant );
229 * Kurdish (Kurdî / كوردی)
233 class LanguageKu
extends LanguageKu_ku
{
235 function __construct() {
237 parent
::__construct();
239 $variants = array( 'ku', 'ku-arab', 'ku-latn' );
240 $variantfallbacks = array(
242 'ku-arab' => 'ku-latn',
243 'ku-latn' => 'ku-arab',
246 $this->mConverter
= new KuConverter( $this, 'ku', $variants, $variantfallbacks );
247 $wgHooks['PageContentSaveComplete'][] = $this->mConverter
;