Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / maintenance / language / digit2html.php
1 <?php
2 /**
3 * Check digit transformation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup MaintenanceLanguage
22 */
23
24 require_once __DIR__ . '/../Maintenance.php';
25
26 /**
27 * Maintenance script that check digit transformation.
28 *
29 * @ingroup MaintenanceLanguage
30 */
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;