Restore location paths in ldapsaisie.pot file but make it relative

This commit is contained in:
Benjamin Renard 2022-06-14 17:05:53 +02:00
parent 4ae9e304ad
commit fd81cb496f
3 changed files with 1942 additions and 1315 deletions

View file

@ -317,10 +317,13 @@ class LScli extends LSlog_staticLoggerClass {
* @param[in] $command string|array The command. It's could be an array of the command with its arguments.
* @param[in] $data_stdin string|null The command arguments (optional, default: null)
* @param[in] $escape_command_args boolean If true, the command will be escaped (optional, default: true)
* @param[in] $cwd string|null The initial working dir for the command
* (optional, default: null = use current PHP
* process working directory)
*
* @retval false|array An array of return code, stdout and stderr result or False in case of fatal error
**/
public static function run_external_command($command, $data_stdin=null, $escape_command_args=true) {
public static function run_external_command($command, $data_stdin=null, $escape_command_args=true, $cwd=null) {
if (array($command))
$command = implode(' ', $command);
if ($escape_command_args)
@ -331,7 +334,7 @@ class LScli extends LSlog_staticLoggerClass {
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w"), // stderr
);
$process = proc_open($command, $descriptorspec, $pipes);
$process = proc_open($command, $descriptorspec, $pipes, $cwd);
if (!is_resource($process)) {
self :: log_error("Fail to run external command: '$command'");

View file

@ -1059,9 +1059,10 @@ function cli_generate_ldapsaisie_pot($command_args) {
// List PHP files to parse
$php_files = LScli :: run_external_command(
array('find', escapeshellarg(LS_ROOT_DIR), '-name', "'*.php'"),
array('find', '-name', "'*.php'"),
null, // no STDIN data
false // do not escape command args (already done)
false, // do not escape command args (already done)
LS_ROOT_DIR // run in LdapSaisie root directory to retreive relative paths
);
if (!is_array($php_files) || $php_files[0] != 0) {
$LSlang_cli_logger -> fatal("Fail to list PHP files.");
@ -1071,7 +1072,6 @@ function cli_generate_ldapsaisie_pot($command_args) {
$result = LScli :: run_external_command(
array(
"xgettext",
"--no-location",
"--from-code utf-8",
"--language=PHP",
"-o", LS_I18N_DIR_PATH."/ldapsaisie-main.pot", // Output
@ -1080,7 +1080,9 @@ function cli_generate_ldapsaisie_pot($command_args) {
"--keyword=___", // Handle custom ___() translation function
"--files=-" // Read files to parse from STDIN
),
$php_files[1] // Pass PHP files list via STDIN
$php_files[1], // Pass PHP files list via STDIN
true, // Escape parameters
LS_ROOT_DIR // Run in LdapSaisie root directory
);
if (!is_array($result) || $result[0] != 0)
$LSlang_cli_logger -> fatal("Fail to extract messages from PHP files using xgettext.");

File diff suppressed because it is too large Load diff