Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
70.00% |
7 / 10 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
ShConverter | |
70.00% |
7 / 10 |
|
80.00% |
4 / 5 |
5.68 | |
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% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
translate | |
100.00% |
1 / 1 |
|
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 | */ |
20 | |
21 | /** |
22 | * Converts Serbo-Croatian from Latin script to Cyrillic script |
23 | * |
24 | * @ingroup Languages |
25 | */ |
26 | class ShConverter extends LanguageConverter { |
27 | |
28 | private const TO_CYRILLIC = [ |
29 | 'dž' => 'џ', |
30 | 'lj' => 'љ', |
31 | 'nj' => 'њ', |
32 | 'Dž' => 'Џ', |
33 | 'DŽ' => 'Џ', |
34 | 'Lj' => 'Љ', |
35 | 'LJ' => 'Љ', |
36 | 'Nj' => 'Њ', |
37 | 'NЈ' => 'Њ', |
38 | |
39 | 'a' => 'а', |
40 | 'b' => 'б', |
41 | 'c' => 'ц', |
42 | 'č' => 'ч', |
43 | 'ć' => 'ћ', |
44 | 'd' => 'д', |
45 | 'đ' => 'ђ', |
46 | 'e' => 'е', |
47 | 'f' => 'ф', |
48 | 'g' => 'г', |
49 | 'h' => 'х', |
50 | 'i' => 'и', |
51 | 'j' => 'ј', |
52 | 'k' => 'к', |
53 | 'l' => 'л', |
54 | 'm' => 'м', |
55 | 'n' => 'н', |
56 | 'o' => 'о', |
57 | 'p' => 'п', |
58 | 'r' => 'р', |
59 | 's' => 'с', |
60 | 'š' => 'ш', |
61 | 't' => 'т', |
62 | 'u' => 'у', |
63 | 'v' => 'в', |
64 | 'z' => 'з', |
65 | 'ž' => 'ж', |
66 | |
67 | 'A' => 'А', |
68 | 'B' => 'Б', |
69 | 'C' => 'Ц', |
70 | 'Č' => 'Ч', |
71 | 'Ć' => 'Ћ', |
72 | 'D' => 'Д', |
73 | 'Đ' => 'Ђ', |
74 | 'E' => 'Е', |
75 | 'F' => 'Ф', |
76 | 'G' => 'Г', |
77 | 'H' => 'Х', |
78 | 'I' => 'И', |
79 | 'J' => 'Ј', |
80 | 'K' => 'К', |
81 | 'L' => 'Л', |
82 | 'M' => 'М', |
83 | 'N' => 'Н', |
84 | 'O' => 'О', |
85 | 'P' => 'П', |
86 | 'R' => 'Р', |
87 | 'S' => 'С', |
88 | 'Š' => 'Ш', |
89 | 'T' => 'Т', |
90 | 'U' => 'У', |
91 | 'V' => 'В', |
92 | 'Z' => 'З', |
93 | 'Ž' => 'Ж', |
94 | ]; |
95 | |
96 | public function getMainCode(): string { |
97 | return 'sh'; |
98 | } |
99 | |
100 | public function getLanguageVariants(): array { |
101 | return [ 'sh-latn', 'sh-cyrl' ]; |
102 | } |
103 | |
104 | public function getVariantsFallbacks(): array { |
105 | return [ |
106 | 'sh-cyrl' => 'sh-latn', |
107 | ]; |
108 | } |
109 | |
110 | protected function loadDefaultTables(): array { |
111 | return [ |
112 | 'sh-cyrl' => new ReplacementArray( self::TO_CYRILLIC ), |
113 | 'sh-latn' => new ReplacementArray(), |
114 | ]; |
115 | } |
116 | |
117 | /** |
118 | * Omits roman numbers |
119 | * |
120 | * @inheritDoc |
121 | */ |
122 | public function translate( $text, $variant ) { |
123 | return $this->translateWithoutRomanNumbers( $text, $variant ); |
124 | } |
125 | } |