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