Add script to generate a table of missing terms in a language. Edit to set $language, then run in a browser and copy-paste in a spreadsheet soft to hand out to professional translators - refs BT#12413
parent
5c044175aa
commit
0767c9b06b
@ -0,0 +1,53 @@ |
||||
<?php /* For licensing terms, see /license.txt */ |
||||
/** |
||||
* Generate a file with the undefined terms of one language and another file with the existing English terms. |
||||
* Copy-paste the resulting page in an Excel spreasheet to have it ready to go for translators |
||||
* @package chamilo.cron |
||||
*/ |
||||
/** |
||||
* Includes and declarations |
||||
*/ |
||||
//die(); |
||||
require_once '../../inc/global.inc.php'; |
||||
$path = api_get_path(SYS_LANG_PATH); |
||||
$referenceLanguage = 'english'; |
||||
$language = 'german'; |
||||
ini_set('memory_limit','128M'); |
||||
/** |
||||
* Main code |
||||
*/ |
||||
$referenceTerms = array(); |
||||
$file = $path . $referenceLanguage . '/trad4all.inc.php'; |
||||
if (is_file($file)) { |
||||
$referenceTerms = array_merge($referenceTerms, SubLanguageManager::get_all_language_variable_in_file($file,true)); |
||||
} |
||||
// get only the array keys (the language variables defined in language files) |
||||
$definedTerms = array_flip(array_keys($referenceTerms)); |
||||
//$referenceTerms = null; |
||||
|
||||
// now get all terms found in all PHP files of Chamilo (this takes some time and memory) |
||||
$missingTerms = array(); |
||||
$nonMissingTerms = array(); |
||||
$l = strlen(api_get_path(SYS_PATH)); |
||||
$file = $path . $language . '/trad4all.inc.php'; |
||||
if (is_file($file)) { |
||||
$nonMissingTerms = array_merge($nonMissingTerms, SubLanguageManager::get_all_language_variable_in_file($file,true)); |
||||
} |
||||
$nonMissingTerms = array_flip(array_keys($nonMissingTerms)); |
||||
|
||||
$missingTerms = array_diff($definedTerms, $nonMissingTerms); |
||||
|
||||
echo "<table border='1'>\n"; |
||||
echo "<tr><th>Count</th><th>Term</th><th>English</th><th>German</th></tr>"; |
||||
$i = 1; |
||||
$countWords = 0; |
||||
foreach ($missingTerms as $term => $value) { |
||||
if (isset($referenceTerms[$term])) { |
||||
$trimmed = trim($referenceTerms[$term],';" '); |
||||
$countWords += str_word_count($trimmed); |
||||
echo "<tr><td>$i</td><td>$term</td><td>".$trimmed."</td><td></td></tr>\n"; |
||||
} |
||||
$i++; |
||||
} |
||||
echo "</table>\n"; |
||||
echo "Total words to be translated: ".$countWords.PHP_EOL; |
Loading…
Reference in new issue