MediaWiki master
digit2html.php
Go to the documentation of this file.
1<?php
24// @codeCoverageIgnoreStart
25require_once __DIR__ . '/../Maintenance.php';
26// @codeCoverageIgnoreEnd
27
33class Digit2Html extends Maintenance {
34
39 private $mLangs = [
40 'Ar', 'As', 'Bh', 'Bo', 'Dz',
41 'Fa', 'Gu', 'Hi', 'Km', 'Kn',
42 'Ks', 'Lo', 'Ml', 'Mr', 'Ne',
43 'New', 'Or', 'Pa', 'Pi', 'Sa'
44 ];
45
46 public function __construct() {
47 parent::__construct();
48 $this->addDescription( 'Check digit transformation' );
49 }
50
51 public function execute() {
52 $languageNameUtils = $this->getServiceContainer()->getLanguageNameUtils();
53 foreach ( $this->mLangs as $code ) {
54 $filename = $languageNameUtils->getMessagesFileName( $code );
55 $this->output( "Loading language [$code] ..." );
56 unset( $digitTransformTable );
57 require_once $filename;
58 if ( !isset( $digitTransformTable ) ) {
59 $this->error( "\$digitTransformTable not found for lang: $code" );
60 continue;
61 }
62
63 $this->output( "OK\n\$digitTransformTable = [\n" );
64 foreach ( $digitTransformTable as $latin => $translation ) {
65 $htmlent = bin2hex( $translation );
66 $this->output( "'$latin' => '$translation', # &#x$htmlent;\n" );
67 }
68 $this->output( "];\n" );
69 }
70 }
71}
72
73// @codeCoverageIgnoreStart
74$maintClass = Digit2Html::class;
75require_once RUN_MAINTENANCE_IF_MAIN;
76// @codeCoverageIgnoreEnd
$digitTransformTable
Maintenance script that check digit transformation.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
$maintClass