MediaWiki  master
digit2html.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/../Maintenance.php';
25 
31 class Digit2Html extends Maintenance {
32 
33  # A list of unicode numerals is available at:
34  # https://www.fileformat.info/info/unicode/category/Nd/list.htm
35  private $mLangs = [
36  'Ar', 'As', 'Bh', 'Bo', 'Dz',
37  'Fa', 'Gu', 'Hi', 'Km', 'Kn',
38  'Ks', 'Lo', 'Ml', 'Mr', 'Ne',
39  'New', 'Or', 'Pa', 'Pi', 'Sa'
40  ];
41 
42  public function __construct() {
43  parent::__construct();
44  $this->addDescription( 'Check digit transformation' );
45  }
46 
47  public function execute() {
48  foreach ( $this->mLangs as $code ) {
49  $filename = Language::getMessagesFileName( $code );
50  $this->output( "Loading language [$code] ... " );
51  unset( $digitTransformTable );
52  require_once $filename;
53  if ( !isset( $digitTransformTable ) ) {
54  $this->error( "\$digitTransformTable not found for lang: $code" );
55  continue;
56  }
57 
58  $this->output( "OK\n\$digitTransformTable = [\n" );
59  foreach ( $digitTransformTable as $latin => $translation ) {
60  $htmlent = bin2hex( $translation );
61  $this->output( "'$latin' => '$translation', # &#x$htmlent;\n" );
62  }
63  $this->output( "];\n" );
64  }
65  }
66 }
67 
68 $maintClass = Digit2Html::class;
69 require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
error( $err, $die=0)
Throw an error to the user.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
Maintenance script that check digit transformation.
Definition: digit2html.php:31
$digitTransformTable
Definition: MessagesAr.php:88
addDescription( $text)
Set the description text.
$maintClass
Definition: digit2html.php:68
output( $out, $channel=null)
Throw some output to the user.
static getMessagesFileName( $code)
Definition: Language.php:4469