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