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
25 * Kurdish converter routines
29 class KuConverter
extends LanguageConverter
{
30 public $mArabicToLatin = [
31 'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h',
32 'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l',
33 'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş',
34 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z',
36 // ک و => ku -- ist richtig
37 // و ك=> ku -- ist auch richtig
39 /* Doppel- und Halbvokale */
43 # 'ئێ' => 'ê', # initial e
45 'ه' => 'e', # with one non-joiner
46 'ه' => 'e', # with two non-joiner
50 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH
51 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA
54 'ئ' => '', # initial hemze should not be shown
60 '٠' => '0', # ٠
61 '١' => '1', # ١
62 '٢' => '2', # ٢
63 '٣' => '3', # ٣
64 '٤' => '4', # ٤
65 '٥' => '5', # ٥
66 '٦' => '6', # ٦
67 '٧' => '7', # ٧
68 '٨' => '8', # ٨
69 '٩' => '9', # ٩
72 public $mLatinToArabic = [
73 'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ',
74 'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل',
75 'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش',
76 't' => 'ت', 'v' => 'ڤ',
77 'x' => 'خ', 'y' => 'ی', 'z' => 'ز',
79 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', 'H' => 'ھ',
80 'H' => 'ہ', 'H' => 'ه', 'H' => 'ح', 'J' => 'ژ', 'K' => 'ك', 'K' => 'ک', 'L' => 'ل',
81 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش',
82 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ',
83 'Y' => 'ی', 'Z' => 'ز',
85 /* Doppelkonsonanten */
86 # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln
87 # 'rr' => 'ڕ', # selbiges für doppel-r
89 /* Einzelne Großbuchstaben */
105 # Try to replace the leading vowel
127 # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu
128 # häufig, um sie als eyn zu interpretieren.
131 /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-(
133 '0' => '٠', # ٠
134 '1' => '١', # ١
135 '2' => '٢', # ٢
136 '3' => '٣', # ٣
137 '4' => '٤', # ٤
138 '5' => '٥', # ٥
139 '6' => '٦', # ٦
140 '7' => '٧', # ٧
141 '8' => '٨', # ٨
142 '9' => '٩', # ٩
146 function loadDefaultTables() {
148 'ku-latn' => new ReplacementArray( $this->mArabicToLatin
),
149 'ku-arab' => new ReplacementArray( $this->mLatinToArabic
),
150 'ku' => new ReplacementArray()
155 * A function wrapper:
156 * - if there is no selected variant, leave the link
158 * - do not try to find variants for usernames
160 * @param string &$link
162 * @param bool $ignoreOtherCond
164 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
165 // check for user namespace
166 if ( is_object( $nt ) ) {
167 $ns = $nt->getNamespace();
168 if ( $ns == NS_USER ||
$ns == NS_USER_TALK
) {
174 parent
::findVariantLink( $link, $nt, $ignoreOtherCond );
175 if ( $this->getPreferredVariant() == $this->mMainLanguageCode
) {
181 * It translates text into variant, specials:
182 * - ommiting roman numbers
184 * @param string $text
185 * @param bool $toVariant
187 * @throws MWException
190 function translate( $text, $toVariant ) {
192 /* From Kazakh interface, maybe we need it later
193 $breaks = '[^\w\x80-\xff]';
194 // regexp for roman numbers
195 $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
198 $reg = '/^'.$roman.'$|^'.$roman.$breaks.'|'.$breaks.$roman.'$|'.$breaks.$roman.$breaks.'/';
200 $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
202 $m = array_shift($matches);
203 if( !isset( $this->mTables[$toVariant] ) ) {
204 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
206 $ret = $this->mTables[$toVariant]->replace( $m[0] );
207 $mstart = $m[1]+strlen($m[0]);
208 foreach($matches as $m) {
209 $ret .= substr($text, $mstart, $m[1]-$mstart);
210 $ret .= parent::translate($m[0], $toVariant);
211 $mstart = $m[1] + strlen($m[0]);
217 if ( !isset( $this->mTables
[$toVariant] ) ) {
218 throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables
) ) );
221 return parent
::translate( $text, $toVariant );
226 * Kurdish (Kurdî / كوردی)
230 class LanguageKu
extends LanguageKu_ku
{
232 function __construct() {
233 parent
::__construct();
235 $variants = [ 'ku', 'ku-arab', 'ku-latn' ];
236 $variantfallbacks = [
238 'ku-arab' => 'ku-latn',
239 'ku-latn' => 'ku-arab',
242 $this->mConverter
= new KuConverter( $this, 'ku', $variants, $variantfallbacks );