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