language: Document sources of data and example usage
[lhc/web/wiklou.git] / maintenance / language / generateNormalizerDataAr.php
index 4338a17..fad35cb 100644 (file)
@@ -28,6 +28,11 @@ require_once __DIR__ . '/../Maintenance.php';
  *
  * This data file is used after normalizing to NFC.
  *
+ * Example usage:
+ *
+ *    curl 'https://unicode.org/Public/6.0.0/ucd/UnicodeData.txt' > /tmp/UnicodeData.txt
+ *    php generateNormalizerDataAr.php --unicode-data-file /tmp/UnicodeData.txt
+ *
  * @ingroup MaintenanceLanguage
  */
 class GenerateNormalizerDataAr extends Maintenance {
@@ -35,7 +40,7 @@ class GenerateNormalizerDataAr extends Maintenance {
                parent::__construct();
                $this->addDescription( 'Generate the normalizer data file for Arabic' );
                $this->addOption( 'unicode-data-file', 'The local location of the data file ' .
-                       'from http://unicode.org/Public/UNIDATA/UnicodeData.txt', false, true );
+                       'from https://unicode.org/Public/6.0.0/ucd/UnicodeData.txt', false, true );
        }
 
        public function getDbType() {
@@ -61,7 +66,7 @@ class GenerateNormalizerDataAr extends Maintenance {
                        $this->fatalError( 'Unable to open the data file.' );
                }
 
-               // For the file format, see http://www.unicode.org/reports/tr44/
+               // For the file format, see https://www.unicode.org/reports/tr44/
                $fieldNames = [
                        'Code',
                        'Name',
@@ -122,10 +127,14 @@ class GenerateNormalizerDataAr extends Maintenance {
                }
 
                global $IP;
-               file_put_contents( "$IP/serialized/normalize-ar.ser", serialize( $pairs ) );
+               file_put_contents( "$IP/languages/data/normalize-ar.php", wfMakeStaticArrayFile(
+                       $pairs,
+                       'File created by generateNormalizerDataAr.php'
+               ) );
+
                echo "ar: " . count( $pairs ) . " pairs written.\n";
        }
 }
 
-$maintClass = 'GenerateNormalizerDataAr';
+$maintClass = GenerateNormalizerDataAr::class;
 require_once RUN_MAINTENANCE_IF_MAIN;