diff --git a/src/includes/class/class.LSlang.php b/src/includes/class/class.LSlang.php index 57e03a83..e83a62bc 100644 --- a/src/includes/class/class.LSlang.php +++ b/src/includes/class/class.LSlang.php @@ -499,14 +499,13 @@ function _cli_add_possible_values_from_LSconfig($context, $withouts, $level=0) { function _cli_parse_template_file($file) { global $LSlang_cli_logger; $LSlang_cli_logger -> debug("Looking for string to translate in '$file' template file"); - $count = 0; - foreach(file($file) as $line) { - $count ++; - if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) { - foreach($matches[1] as $t) { + foreach(file($file) as $line_count => $line) { + $line_count ++; + if (preg_match_all('/\{ *tr +.*msg=(["\'])(?P[^"}]+)\1.*\}/', $line, $matches)) { + foreach($matches["msg"] as $t) { $t = preg_replace('/[\'"]\|escape\:.*$/', '', $t); - $LSlang_cli_logger -> trace(" - \"$t\" # Line $count"); - _cli_add_str_to_translate($t, _cli_absolute2relative_path($file).":$count"); + $LSlang_cli_logger -> trace(" - \"$t\" # Line $line_count"); + _cli_add_str_to_translate($t, _cli_absolute2relative_path($file).":$line_count"); } } } @@ -520,15 +519,17 @@ function _cli_parse_template_file($file) { * @return void */ function _cli_find_and_parse_template_file($dir) { + global $LSlang_cli_logger; if (is_dir($dir)) { + $LSlang_cli_logger -> debug("Looking for string to translate in template directory '$dir'"); if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file=='.' || $file=='..') continue; - if (is_dir($dir.'/'.$file)) { - _cli_find_and_parse_template_file($dir.'/'.$file); + if (is_dir("$dir/$file")) { + _cli_find_and_parse_template_file("$dir/$file"); } elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) { - _cli_parse_template_file($dir.'/'.$file); + _cli_parse_template_file("$dir/$file"); } } closedir($dh); diff --git a/src/includes/class/class.LStemplate.php b/src/includes/class/class.LStemplate.php index f8217c5f..a2bb4cc5 100644 --- a/src/includes/class/class.LStemplate.php +++ b/src/includes/class/class.LStemplate.php @@ -705,7 +705,9 @@ function LStemplate_smarty_getFData($params) { } function LStemplate_smarty_tr($params) { - echo __($params['msg']); + $msg = __($params['msg']); + unset($params['msg']); + echo $params?getFData($msg, $params):$msg; } function LStemplate_smarty_img($params) {