Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A check for language name differences between MediaWiki core and CLDR (via https://www.mediawiki.org/wiki/Extension:CLDR)
<?php
define('MW_PATH', '../../');
require(MW_PATH . 'languages/data/Names.php');
$coreLanguageNames = MediaWiki\Languages\Data\Names::$names;
echo "{|\n";
echo "! Lang !! In core !! In CLDR\n";
$dir = opendir('CldrNames');
if (!$dir) {
echo 'Unable to read CldrNames';
return;
}
while (false !== ($entry = readdir($dir))) {
if (preg_match('/^CldrNames([^.]+)\.php$/', $entry, $matches)) {
$lang = strtolower(str_replace('_', '-', $matches[1]));
// unset($languageNames);
require( "CldrNames/$entry" );
$hasCore = isset($coreLanguageNames[$lang]);
$hasCldr = isset($languageNames[$lang]);
if (!$hasCore || !$hasCldr) {
echo "|- lang='$lang'\n";
echo "| $lang || ";
echo $hasCore ? $coreLanguageNames[$lang] : "''undefined''";
echo " || ";
echo $hasCldr ? $languageNames[$lang] : "''undefined''";
echo "\n";
} else if ( $languageNames[$lang] != $coreLanguageNames[$lang] ) {
echo "|- lang='$lang'\n";
echo "| $lang || ${coreLanguageNames[$lang]} || ${languageNames[$lang]}\n";
}
}
}
closedir($dir);
echo "|}\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.