1
0
Fork 0
mirror of https://gitlab.easter-eggs.com/ee/ldapsaisie.git synced 2024-12-23 00:43:48 +01:00

generate_lang_file.php : manage messages string in templates files

This commit is contained in:
Benjamin Renard 2015-07-30 16:40:26 +02:00
parent 0055ea1d7a
commit ddf474d6fe

View file

@ -188,6 +188,40 @@ if (loadDir('../'.LS_OBJECTS_DIR) && loadDir('../'.LS_LOCAL_DIR.LS_OBJECTS_DIR))
} }
} }
/*
* Manage template file
*/
function parse_template_file($file) {
foreach(file($file) as $line) {
if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) {
foreach($matches[1] as $t)
add($t);
}
}
}
function find_and_parse_template_file($dir) {
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file=='.' || $file=='..') continue;
if (is_dir($dir.'/'.$file)) {
find_and_parse_template_file($dir.'/'.$file);
}
elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) {
parse_template_file($dir.'/'.$file);
}
}
closedir($dh);
}
}
}
find_and_parse_template_file('../'.LS_TEMPLATES_DIR);
find_and_parse_template_file('../'.LS_LOCAL_DIR.LS_TEMPLATES_DIR);
ksort($data); ksort($data);
echo "<?php\n\n"; echo "<?php\n\n";