-
-
Save dannevang/ec63cd0d83e28df3e519 to your computer and use it in GitHub Desktop.
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 | |
$default = realpath(dirname(__FILE__).'/core/lexicon/en').'/'; | |
$local = realpath(dirname(__FILE__).'/core/lexicon/nl').'/'; | |
$showSame = false; | |
// find default files | |
$theFiles = array(); | |
if($handle = opendir($default)) { | |
while(false !== ($file = readdir($handle))) { | |
if($file != '.' && $file != '..' && is_file($default.$file)) { | |
$theFiles[] = $file; | |
} | |
} | |
closedir($handle); | |
} | |
sort($theFiles); | |
// compare | |
$_lang = array(); | |
foreach($theFiles as $filename) { | |
// load the local file | |
if (file_exists($local.$filename)) { | |
require_once($local.$filename); | |
$localLang = $_lang; | |
unset($_lang); | |
} else { | |
echo '<strong>'.$filename.'</strong><br /> <span style="color: red;">File '.$filename.' does not exist in translated file</span><br /><br />'; | |
continue; | |
} | |
// load the default | |
require_once($default.$filename); | |
$defaultLang = $_lang; | |
unset($_lang); | |
echo '<strong>'.$filename.'</strong><br />'; | |
// compare keys | |
foreach ($defaultLang as $key => $value) { | |
if (!isset($localLang[$key])) { | |
echo ' '; | |
echo 'The key <span style="color:red;">"'.$key.'"</span> <strong>doesn\'t exists</strong> in translated file<br />'; | |
} | |
else if ($showSame && ($localLang[$key] == $value)) { | |
echo ' '; | |
echo '<span style="color:gray;">The value of key "'.$key.'" is the <strong>same as the default</strong> '; | |
echo '(<strong>'.strip_tags(substr($localLang[$key], 0, 40)).'...</strong> vs. <strong>'.strip_tags(substr($value, 0, 40)).'...</strong>)</span><br />'; | |
} | |
} | |
foreach ($localLang as $key => $value) { | |
if(!isset($defaultLang[$key])) { | |
echo ' '; | |
echo 'The key "'.$key.'" exists in the translated file, but is <span style="color:blue;">removed by the default</span>.<br />'; | |
} | |
} | |
echo '<br />'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment