Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
62.50% |
10 / 16 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
KuConverter | |
62.50% |
10 / 16 |
|
60.00% |
3 / 5 |
7.90 | |
0.00% |
0 / 1 |
getMainCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getLanguageVariants | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getVariantsFallbacks | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
loadDefaultTables | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
translate | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | /** |
22 | * Kurdish converter routines. |
23 | * |
24 | * @ingroup Languages |
25 | */ |
26 | class KuConverter extends LanguageConverterSpecific { |
27 | |
28 | /** |
29 | * @var string[] |
30 | */ |
31 | public $mArabicToLatin = [ |
32 | 'ب' => 'b', 'ج' => 'c', 'چ' => 'ç', 'د' => 'd', 'ف' => 'f', 'گ' => 'g', 'ھ' => 'h', |
33 | 'ہ' => 'h', 'ه' => 'h', 'ح' => 'h', 'ژ' => 'j', 'ك' => 'k', 'ک' => 'k', 'ل' => 'l', |
34 | 'م' => 'm', 'ن' => 'n', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r', 'س' => 's', 'ش' => 'ş', |
35 | 'ت' => 't', 'ڤ' => 'v', 'خ' => 'x', 'غ' => 'x', 'ز' => 'z', |
36 | |
37 | // ک و => ku -- ist richtig |
38 | // و ك=> ku -- ist auch richtig |
39 | |
40 | /* Doppel- und Halbvokale */ |
41 | 'ڵ' => 'll', # ll |
42 | 'ڕ' => 'rr', # rr |
43 | 'ا' => 'a', |
44 | # 'ئێ' => 'ê', # initial e |
45 | 'ە' => 'e', |
46 | 'ه' => 'e', # with one non-joiner |
47 | 'ه' => 'e', # with two non-joiners |
48 | 'ة' => 'e', |
49 | 'ێ' => 'ê', |
50 | 'ي' => 'î', |
51 | 'ی' => 'î', # U+06CC db 8c ARABIC LETTER FARSI YEH |
52 | 'ى' => 'î', # U+0649 d9 89 ARABIC LETTER ALEF MAKSURA |
53 | 'ۆ' => 'o', |
54 | 'و' => 'w', |
55 | 'ئ' => '', # initial hemze should not be shown |
56 | '،' => ',', |
57 | 'ع' => '\'', # ayn |
58 | '؟' => '?', |
59 | |
60 | # digits |
61 | '٠' => '0', # U+0660 |
62 | '١' => '1', # U+0661 |
63 | '٢' => '2', # U+0662 |
64 | '٣' => '3', # U+0663 |
65 | '٤' => '4', # U+0664 |
66 | '٥' => '5', # U+0665 |
67 | '٦' => '6', # U+0666 |
68 | '٧' => '7', # U+0667 |
69 | '٨' => '8', # U+0668 |
70 | '٩' => '9', # U+0669 |
71 | ]; |
72 | |
73 | /** |
74 | * @var string[] |
75 | */ |
76 | public $mLatinToArabic = [ |
77 | 'b' => 'ب', 'c' => 'ج', 'ç' => 'چ', 'd' => 'د', 'f' => 'ف', 'g' => 'گ', |
78 | 'h' => 'ه', 'j' => 'ژ', 'k' => 'ک', 'l' => 'ل', |
79 | 'm' => 'م', 'n' => 'ن', 'p' => 'پ', 'q' => 'ق', 'r' => 'ر', 's' => 'س', 'ş' => 'ش', |
80 | 't' => 'ت', 'v' => 'ڤ', |
81 | 'x' => 'خ', 'y' => 'ی', 'z' => 'ز', |
82 | |
83 | 'B' => 'ب', 'C' => 'ج', 'Ç' => 'چ', 'D' => 'د', 'F' => 'ف', 'G' => 'گ', |
84 | 'H' => 'ح', 'J' => 'ژ', 'K' => 'ک', 'L' => 'ل', |
85 | 'M' => 'م', 'N' => 'ن', 'P' => 'پ', 'Q' => 'ق', 'R' => 'ر', 'S' => 'س', 'Ş' => 'ش', |
86 | 'T' => 'ت', 'V' => 'ڤ', 'W' => 'و', 'X' => 'خ', |
87 | 'Y' => 'ی', 'Z' => 'ز', |
88 | |
89 | /* Doppelkonsonanten */ |
90 | # 'll' => 'ڵ', # wenn es geht, doppel-l und l getrennt zu behandeln |
91 | # 'rr' => 'ڕ', # selbiges für doppel-r |
92 | |
93 | /* Einzelne Großbuchstaben */ |
94 | // ' C' => 'ج', |
95 | |
96 | /* Vowels */ |
97 | 'a' => 'ا', |
98 | 'e' => 'ە', |
99 | 'ê' => 'ێ', |
100 | 'i' => '', |
101 | 'î' => 'ی', |
102 | 'o' => 'ۆ', |
103 | 'u' => 'و', |
104 | 'û' => 'وو', |
105 | 'w' => 'و', |
106 | ',' => '،', |
107 | '?' => '؟', |
108 | |
109 | # Try to replace the leading vowel |
110 | ' a' => 'ئا ', |
111 | ' e' => 'ئە ', |
112 | ' ê' => 'ئێ ', |
113 | ' î' => 'ئی ', |
114 | ' o' => 'ئۆ ', |
115 | ' u' => 'ئو ', |
116 | ' û' => 'ئوو ', |
117 | 'A' => 'ئا', |
118 | 'E' => 'ئە', |
119 | 'Ê' => 'ئێ', |
120 | 'Î' => 'ئی', |
121 | 'O' => 'ئۆ', |
122 | 'U' => 'ئو', |
123 | 'Û' => 'ئوو', |
124 | ' A' => 'ئا ', |
125 | ' E' => 'ئە ', |
126 | ' Ê' => 'ئێ ', |
127 | ' Î' => 'ئی ', |
128 | ' O' => 'ئۆ ', |
129 | ' U' => 'ئو ', |
130 | ' Û' => 'ئوو ', |
131 | # eyn erstmal deaktivieren, einfache Anführungsstriche sind einfach zu |
132 | # häufig, um sie als eyn zu interpretieren. |
133 | # '\'' => 'ع', |
134 | |
135 | /* # deactivated for now, breaks links i.e. in header of Special:Recentchanges :-( |
136 | # digits |
137 | '0' => '٠', # U+0660 |
138 | '1' => '١', # U+0661 |
139 | '2' => '٢', # U+0662 |
140 | '3' => '٣', # U+0663 |
141 | '4' => '٤', # U+0664 |
142 | '5' => '٥', # U+0665 |
143 | '6' => '٦', # U+0666 |
144 | '7' => '٧', # U+0667 |
145 | '8' => '٨', # U+0668 |
146 | '9' => '٩', # U+0669 |
147 | */ |
148 | ]; |
149 | |
150 | public function getMainCode(): string { |
151 | return 'ku'; |
152 | } |
153 | |
154 | public function getLanguageVariants(): array { |
155 | return [ 'ku', 'ku-arab', 'ku-latn' ]; |
156 | } |
157 | |
158 | public function getVariantsFallbacks(): array { |
159 | return [ |
160 | 'ku' => 'ku-latn', |
161 | 'ku-arab' => 'ku-latn', |
162 | 'ku-latn' => 'ku-arab', |
163 | ]; |
164 | } |
165 | |
166 | protected function loadDefaultTables(): array { |
167 | return [ |
168 | 'ku-latn' => new ReplacementArray( $this->mArabicToLatin ), |
169 | 'ku-arab' => new ReplacementArray( $this->mLatinToArabic ), |
170 | 'ku' => new ReplacementArray() |
171 | ]; |
172 | } |
173 | |
174 | public function translate( $text, $toVariant ) { |
175 | $this->loadTables(); |
176 | |
177 | if ( !isset( $this->mTables[$toVariant] ) ) { |
178 | throw new LogicException( 'Broken variant table: ' . implode( ',', array_keys( $this->mTables ) ) ); |
179 | } |
180 | |
181 | return parent::translate( $text, $toVariant ); |
182 | } |
183 | } |