MediaWiki master
generateNormalizerDataMl.php
Go to the documentation of this file.
1<?php
24// @codeCoverageIgnoreStart
25require_once __DIR__ . '/../Maintenance.php';
26// @codeCoverageIgnoreEnd
27
29
37class GenerateNormalizerDataMl extends Maintenance {
38 public function __construct() {
39 parent::__construct();
40 $this->addDescription( 'Generate the normalizer data file for Malayalam' );
41 }
42
43 public function getDbType() {
44 return Maintenance::DB_NONE;
45 }
46
47 public function execute() {
48 $hexPairs = [
49 # From https://www.unicode.org/versions/Unicode5.1.0/#Malayalam_Chillu_Characters
50 '0D23 0D4D 200D' => '0D7A',
51 '0D28 0D4D 200D' => '0D7B',
52 '0D30 0D4D 200D' => '0D7C',
53 '0D32 0D4D 200D' => '0D7D',
54 '0D33 0D4D 200D' => '0D7E',
55
56 # From http://permalink.gmane.org/gmane.science.linguistics.wikipedia.technical/46413
57 '0D15 0D4D 200D' => '0D7F',
58 ];
59
60 $pairs = [];
61 foreach ( $hexPairs as $hexSource => $hexDest ) {
62 $source = UtfNormal\Utils::hexSequenceToUtf8( $hexSource );
63 $dest = UtfNormal\Utils::hexSequenceToUtf8( $hexDest );
64 $pairs[$source] = $dest;
65 }
66
67 global $IP;
68 $writer = new StaticArrayWriter();
69 file_put_contents( "$IP/includes/languages/data/NormalizeMl.php", $writer->writeClass(
70 $pairs,
71 [
72 'header' => 'Generated by generateNormalizerDataMl.php. Do not modify!',
73 'namespace' => 'MediaWiki\\Languages\\Data',
74 'class' => 'NormalizeMl',
75 'const' => 'PAIRS',
76 ]
77 ) );
78
79 echo "ml: " . count( $pairs ) . " pairs written.\n";
80 }
81}
82
83// @codeCoverageIgnoreStart
84$maintClass = GenerateNormalizerDataMl::class;
85require_once RUN_MAINTENANCE_IF_MAIN;
86// @codeCoverageIgnoreEnd
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:102
Generates the normalizer data file for Malayalam.
Format a static PHP array to be written to a file.
$source