Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
70.00% |
7 / 10 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
TlyConverter | |
70.00% |
7 / 10 |
|
75.00% |
3 / 4 |
4.43 | |
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 / 3 |
|
0.00% |
0 / 1 |
2 | |||
loadDefaultTables | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 |
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 | * @author Amir E. Aharoni |
20 | */ |
21 | |
22 | /** |
23 | * Talysh specific code. |
24 | * |
25 | * @ingroup Languages |
26 | */ |
27 | class TlyConverter extends LanguageConverter { |
28 | /** |
29 | * @var string[] |
30 | * The conversion table. |
31 | * The Cyrillic sequence is based on Pireyko's 1976 Talysh—Russian dictionary, |
32 | * with practical additions. |
33 | * The toCyrillic table is built by flipping this one. |
34 | */ |
35 | private $toLatin = [ |
36 | 'а' => 'a', 'А' => 'A', |
37 | 'б' => 'b', 'Б' => 'B', |
38 | 'в' => 'v', 'В' => 'V', |
39 | 'г' => 'q', 'Г' => 'Q', // Not G! |
40 | 'ғ' => 'ğ', 'Ғ' => 'Ğ', |
41 | 'д' => 'd', 'Д' => 'D', |
42 | 'е' => 'e', 'Е' => 'E', |
43 | 'ә' => 'ə', 'Ә' => 'Ə', |
44 | 'ж' => 'j', 'Ж' => 'J', |
45 | 'з' => 'z', 'З' => 'Z', |
46 | |
47 | 'и' => 'i', 'И' => 'İ', // NB Dotted capital I |
48 | 'ы' => 'ı', 'Ы' => 'I', // NB Dotless small I |
49 | 'ј' => 'y', 'Ј' => 'Y', |
50 | 'к' => 'k', 'К' => 'K', |
51 | 'л' => 'l', 'Л' => 'L', |
52 | 'м' => 'm', 'М' => 'M', |
53 | 'н' => 'n', 'Н' => 'N', |
54 | 'о' => 'o', 'О' => 'O', |
55 | 'п' => 'p', 'П' => 'P', |
56 | 'р' => 'r', 'Р' => 'R', |
57 | |
58 | 'с' => 's', 'С' => 'S', |
59 | 'т' => 't', 'Т' => 'T', |
60 | 'у' => 'u', 'У' => 'U', // NB Not in the standard dictionary, but used in practice |
61 | 'ү' => 'ü', 'Ү' => 'Ü', |
62 | 'ф' => 'f', 'Ф' => 'F', |
63 | 'х' => 'x', 'Х' => 'X', |
64 | 'һ' => 'h', 'Һ' => 'H', |
65 | 'ч' => 'ç', 'Ч' => 'Ç', |
66 | 'ҹ' => 'c', 'Ҹ' => 'C', |
67 | 'ш' => 'ş', 'Ш' => 'Ş', |
68 | ]; |
69 | |
70 | /** |
71 | * @var string[] |
72 | * Filled with data in loadDefaultTables by flipping $toLatin. |
73 | */ |
74 | private $toCyrillic = []; |
75 | |
76 | public function getMainCode(): string { |
77 | return 'tly'; |
78 | } |
79 | |
80 | public function getLanguageVariants(): array { |
81 | return [ 'tly', 'tly-cyrl' ]; |
82 | } |
83 | |
84 | public function getVariantsFallbacks(): array { |
85 | return [ |
86 | 'tly-cyrl' => 'tly', |
87 | ]; |
88 | } |
89 | |
90 | protected function loadDefaultTables(): array { |
91 | $this->toCyrillic = array_flip( $this->toLatin ); |
92 | |
93 | return [ |
94 | 'tly-cyrl' => new ReplacementArray( $this->toCyrillic ), |
95 | 'tly' => new ReplacementArray( $this->toLatin ), |
96 | ]; |
97 | } |
98 | } |