Skip to content

Instantly share code, notes, and snippets.

@mormegil-cz
Last active January 22, 2019 14:48
Show Gist options
  • Save mormegil-cz/7240262 to your computer and use it in GitHub Desktop.
Save mormegil-cz/7240262 to your computer and use it in GitHub Desktop.
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