Last active
January 22, 2019 14:48
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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