MediaWiki master
generateNormalizerDataMl.php
Go to the documentation of this file.
1<?php
10// @codeCoverageIgnoreStart
11require_once __DIR__ . '/../Maintenance.php';
12// @codeCoverageIgnoreEnd
13
16
25 public function __construct() {
26 parent::__construct();
27 $this->addDescription( 'Generate the normalizer data file for Malayalam' );
28 }
29
31 public function getDbType() {
32 return Maintenance::DB_NONE;
33 }
34
35 public function execute() {
36 $hexPairs = [
37 # From https://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters
38 '0D23 0D4D 200D' => '0D7A',
39 '0D28 0D4D 200D' => '0D7B',
40 '0D30 0D4D 200D' => '0D7C',
41 '0D32 0D4D 200D' => '0D7D',
42 '0D33 0D4D 200D' => '0D7E',
43
44 # From http://permalink.gmane.org/gmane.science.linguistics.wikipedia.technical/46413
45 '0D15 0D4D 200D' => '0D7F',
46 ];
47
48 $pairs = [];
49 foreach ( $hexPairs as $hexSource => $hexDest ) {
50 $source = UtfNormal\Utils::hexSequenceToUtf8( $hexSource );
51 $dest = UtfNormal\Utils::hexSequenceToUtf8( $hexDest );
52 $pairs[$source] = $dest;
53 }
54
55 global $IP;
56 $writer = new StaticArrayWriter();
57 file_put_contents( "$IP/includes/Languages/Data/NormalizeMl.php", $writer->writeClass(
58 $pairs,
59 [
60 'header' => 'Generated by generateNormalizerDataMl.php. Do not modify!',
61 'namespace' => 'MediaWiki\\Languages\\Data',
62 'class' => 'NormalizeMl',
63 'const' => 'PAIRS',
64 ]
65 ) );
66
67 echo "ml: " . count( $pairs ) . " pairs written.\n";
68 }
69}
70
71// @codeCoverageIgnoreStart
72$maintClass = GenerateNormalizerDataMl::class;
73require_once RUN_MAINTENANCE_IF_MAIN;
74// @codeCoverageIgnoreEnd
if(!defined('MEDIAWIKI')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:90
Generates the normalizer data file for Malayalam.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addDescription( $text)
Set the description text.
Format a static PHP array to be written to a file.
$source