addDescription( 'Script to create language names index.' ); } public function execute() { $languages = Language::fetchLanguageNames( null, 'all' ); $all = []; $buckets = []; foreach ( $languages as $sourceLanguage => $autonym ) { $all[$sourceLanguage][strtolower( $autonym )] = true; $translations = LanguageNames::getNames( $sourceLanguage, 0, 2 ); foreach ( $translations as $targetLanguage => $translation ) { $all[$targetLanguage][] = strtolower( $translation ); } } foreach ( $all as $targetLanguage => $names ) { foreach ( $names as $name ) { $bucket = LanguageNameSearch::getIndex( $name ); $buckets[$bucket][$name] = $targetLanguage; } } $this->output( 'Total buckets: ' . count( $buckets ) . "\n" ); file_put_contents( 'langnames.ser', serialize( $buckets ) ); } } $maintClass = 'LanguageNameIndexer'; require_once RUN_MAINTENANCE_IF_MAIN;