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