seeddms-code/develop/transcomp.php

53 lines
1.4 KiB
PHP
Raw Normal View History

2010-12-14 16:07:56 +00:00
<?php
/* Determine all languages keys used in the php files */
$output = array();
2023-03-01 11:16:41 +00:00
if(exec('sgrep -o "%r\n" \'"tMLText(\"" __ "\""\' */*.php|sort|uniq -c', $output)) {
2010-12-14 16:07:56 +00:00
$allkeys = array();
foreach($output as $line) {
$data = explode(' ', trim($line));
$allkeys[$data[1]] = $data[0];
}
}
/* Reading languages */
2023-03-01 11:16:41 +00:00
foreach(array('en_GB', 'de_DE', 'it_IT', 'sk_SK', 'cs_CZ') as $lang) {
2010-12-14 16:07:56 +00:00
include('languages/'.$lang.'/lang.inc');
ksort($text);
$langarr[$lang] = $text;
}
/* Check for missing phrases in each language */
echo "List of missing keys\n";
echo "-----------------------------\n";
foreach(array_keys($allkeys) as $key) {
2023-03-01 11:16:41 +00:00
foreach(array('en_GB', 'de_DE', 'it_IT', 'sk_SK', 'cs_CZ') as $lang) {
2010-12-14 16:07:56 +00:00
if(!isset($langarr[$lang][$key])) {
echo "Missing key '".$key."' in language ".$lang."\n";
}
}
}
echo "\n";
/* Check for phrases not used anymore */
echo "List of superflous keys\n";
echo "-----------------------------\n";
2023-03-01 11:16:41 +00:00
foreach(array('en_GB', 'de_DE', 'it_IT', 'sk_SK', 'cs_CZ') as $lang) {
2010-12-14 16:07:56 +00:00
$n = 0;
foreach($langarr[$lang] as $key=>$value) {
if(!isset($allkeys[$key])) {
echo "Unused key '".$key."' in language ".$lang."\n";
$n++;
}
}
echo $n." superflous keys found\n";
}
exit;
$fpout = fopen('php://stdout', 'w');
2023-03-01 11:16:41 +00:00
foreach(array_keys($langarr['en_GB']) as $key) {
$data = array($key, $langarr['en_GB'][$key], $langarr['de_DE'][$key]);
2010-12-14 16:07:56 +00:00
fputcsv($fpout, $data);
}
?>