MediaWiki  1.34.0
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;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
Digit2Html\__construct
__construct()
Default constructor.
Definition: digit2html.php:42
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
Language\getMessagesFileName
static getMessagesFileName( $code)
Definition: Language.php:4362
Digit2Html\execute
execute()
Do the actual work.
Definition: digit2html.php:47
Digit2Html\$mLangs
$mLangs
Definition: digit2html.php:35
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:481
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:453
$digitTransformTable
$digitTransformTable
Definition: MessagesAr.php:88
$maintClass
$maintClass
Definition: digit2html.php:68
Digit2Html
Maintenance script that check digit transformation.
Definition: digit2html.php:31