|
@@ -9,17 +9,17 @@
|
|
die();
|
|
die();
|
|
require_once '../../inc/global.inc.php';
|
|
require_once '../../inc/global.inc.php';
|
|
$path = api_get_path(SYS_LANG_PATH).'english';
|
|
$path = api_get_path(SYS_LANG_PATH).'english';
|
|
-ini_set('memory_limit','128M');
|
|
|
|
|
|
+ini_set('memory_limit', '128M');
|
|
/**
|
|
/**
|
|
* Main code
|
|
* Main code
|
|
*/
|
|
*/
|
|
$terms = array();
|
|
$terms = array();
|
|
$list = SubLanguageManager::get_lang_folder_files_list($path);
|
|
$list = SubLanguageManager::get_lang_folder_files_list($path);
|
|
foreach ($list as $entry) {
|
|
foreach ($list as $entry) {
|
|
- $file = $path.'/'.$entry;
|
|
|
|
- if (is_file($file)) {
|
|
|
|
- $terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true));
|
|
|
|
- }
|
|
|
|
|
|
+ $file = $path.'/'.$entry;
|
|
|
|
+ if (is_file($file)) {
|
|
|
|
+ $terms = array_merge($terms, SubLanguageManager::get_all_language_variable_in_file($file, true));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// get only the array keys (the language variables defined in language files)
|
|
// get only the array keys (the language variables defined in language files)
|
|
$defined_terms = array_flip(array_keys($terms));
|
|
$defined_terms = array_flip(array_keys($terms));
|
|
@@ -28,42 +28,46 @@ echo count($defined_terms)." terms were found in language files<br />";
|
|
|
|
|
|
// now get all terms found in all PHP files of Chamilo (this takes some
|
|
// now get all terms found in all PHP files of Chamilo (this takes some
|
|
// time and memory)
|
|
// time and memory)
|
|
-$used_terms = array();
|
|
|
|
|
|
+$usedTerms = array();
|
|
$l = strlen(api_get_path(SYS_PATH));
|
|
$l = strlen(api_get_path(SYS_PATH));
|
|
$files = get_all_php_files(api_get_path(SYS_PATH));
|
|
$files = get_all_php_files(api_get_path(SYS_PATH));
|
|
// Browse files
|
|
// Browse files
|
|
foreach ($files as $file) {
|
|
foreach ($files as $file) {
|
|
- //echo 'Analyzing '.$file."<br />";
|
|
|
|
- $shortfile = substr($file,$l);
|
|
|
|
- //echo 'Analyzing '.$shortfile."<br />";
|
|
|
|
- $lines = file($file);
|
|
|
|
- // Browse lines inside file $file
|
|
|
|
- foreach ($lines as $line) {
|
|
|
|
- $myterms = array();
|
|
|
|
- $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/',$line,$myterms);
|
|
|
|
- if ($res > 0) {
|
|
|
|
- foreach($myterms[1] as $term) {
|
|
|
|
- if (substr($term,0,4)=='lang') { $term = substr($term,4); }
|
|
|
|
- $used_terms[$term] = $shortfile;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- $res = 0;
|
|
|
|
- $res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/',$line,$myterms);
|
|
|
|
- if ($res > 0) {
|
|
|
|
- foreach($myterms[1] as $term) {
|
|
|
|
- if (substr($term,0,4)=='lang') { $term = substr($term,4); }
|
|
|
|
- $used_terms[$term] = $shortfile;
|
|
|
|
|
|
+ //echo 'Analyzing '.$file."<br />";
|
|
|
|
+ $shortFile = substr($file, $l);
|
|
|
|
+ //echo 'Analyzing '.$shortFile."<br />";
|
|
|
|
+ $lines = file($file);
|
|
|
|
+ // Browse lines inside file $file
|
|
|
|
+ foreach ($lines as $line) {
|
|
|
|
+ $myTerms = array();
|
|
|
|
+ $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myTerms);
|
|
|
|
+ if ($res > 0) {
|
|
|
|
+ foreach ($myTerms[1] as $term) {
|
|
|
|
+ if (substr($term, 0, 4)=='lang') {
|
|
|
|
+ $term = substr($term, 4);
|
|
|
|
+ }
|
|
|
|
+ $usedTerms[$term] = $shortFile;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $res = 0;
|
|
|
|
+ $res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/', $line, $myTerms);
|
|
|
|
+ if ($res > 0) {
|
|
|
|
+ foreach ($myTerms[1] as $term) {
|
|
|
|
+ if (substr($term, 0, 4)=='lang') {
|
|
|
|
+ $term = substr($term, 4);
|
|
|
|
+ }
|
|
|
|
+ $usedTerms[$term] = $shortFile;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- flush();
|
|
|
|
|
|
+ flush();
|
|
}
|
|
}
|
|
|
|
|
|
// Compare defined terms VS used terms. Used terms should be smaller than
|
|
// Compare defined terms VS used terms. Used terms should be smaller than
|
|
// defined terms, and this should prove the concept that there are much
|
|
// defined terms, and this should prove the concept that there are much
|
|
// more variables than what we really use
|
|
// more variables than what we really use
|
|
-if (count($used_terms)<1) {
|
|
|
|
|
|
+if (count($usedTerms)<1) {
|
|
die("No used terms<br />\n");
|
|
die("No used terms<br />\n");
|
|
} else {
|
|
} else {
|
|
echo "The following terms were defined but never used: <br />\n<table>";
|
|
echo "The following terms were defined but never used: <br />\n<table>";
|
|
@@ -72,7 +76,7 @@ $i = 1;
|
|
foreach ($defined_terms as $term => $file) {
|
|
foreach ($defined_terms as $term => $file) {
|
|
// remove "lang" prefix just in case
|
|
// remove "lang" prefix just in case
|
|
if (substr($term,0,4)=='lang') { $term = substr($term,4); }
|
|
if (substr($term,0,4)=='lang') { $term = substr($term,4); }
|
|
- if (!isset($used_terms[$term])) {
|
|
|
|
|
|
+ if (!isset($usedTerms[$term])) {
|
|
echo "<tr><td>$i</td><td>$term</td></tr>\n";
|
|
echo "<tr><td>$i</td><td>$term</td></tr>\n";
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|