Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 31
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
GenerateNormalizerDataMl
0.00% covered (danger)
0.00%
0 / 28
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getDbType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * Generates the normalizer data file for Malayalam.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup MaintenanceLanguage
22 */
23
24require_once __DIR__ . '/../Maintenance.php';
25
26use Wikimedia\StaticArrayWriter;
27
28/**
29 * Generates the normalizer data file for Malayalam.
30 *
31 * This data file is used after normalizing to NFC.
32 *
33 * @ingroup MaintenanceLanguage
34 */
35class GenerateNormalizerDataMl extends Maintenance {
36    public function __construct() {
37        parent::__construct();
38        $this->addDescription( 'Generate the normalizer data file for Malayalam' );
39    }
40
41    public function getDbType() {
42        return Maintenance::DB_NONE;
43    }
44
45    public function execute() {
46        $hexPairs = [
47            # From https://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters
48            '0D23 0D4D 200D' => '0D7A',
49            '0D28 0D4D 200D' => '0D7B',
50            '0D30 0D4D 200D' => '0D7C',
51            '0D32 0D4D 200D' => '0D7D',
52            '0D33 0D4D 200D' => '0D7E',
53
54            # From http://permalink.gmane.org/gmane.science.linguistics.wikipedia.technical/46413
55            '0D15 0D4D 200D' => '0D7F',
56        ];
57
58        $pairs = [];
59        foreach ( $hexPairs as $hexSource => $hexDest ) {
60            $source = UtfNormal\Utils::hexSequenceToUtf8( $hexSource );
61            $dest = UtfNormal\Utils::hexSequenceToUtf8( $hexDest );
62            $pairs[$source] = $dest;
63        }
64
65        global $IP;
66        $writer = new StaticArrayWriter();
67        file_put_contents( "$IP/includes/languages/data/NormalizeMl.php", $writer->writeClass(
68            $pairs,
69            [
70                'header' => 'Generated by generateNormalizerDataMl.php. Do not modify!',
71                'namespace' => 'MediaWiki\\Languages\\Data',
72                'class' => 'NormalizeMl',
73                'const' => 'PAIRS',
74            ]
75        ) );
76
77        echo "ml: " . count( $pairs ) . " pairs written.\n";
78    }
79}
80
81$maintClass = GenerateNormalizerDataMl::class;
82require_once RUN_MAINTENANCE_IF_MAIN;