From 93aeb32660c2a6a60c47692c7f98f12b1e950204 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 22 Nov 2023 12:46:07 +0100 Subject: [PATCH] I18n: add extract_messages_excluded_paths parameter --- example/includes/core.php | 9 ++++++--- src/I18n.php | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/example/includes/core.php b/example/includes/core.php index 9940b31..8843155 100644 --- a/example/includes/core.php +++ b/example/includes/core.php @@ -39,11 +39,14 @@ App::init( "$root_dir_path/static" ), ), + 'i18n' => array( + 'default_locale' => "en_US.UTF8", + 'extract_messages_excluded_paths' => array( + "static/lib" + ), + ), 'default' => array( 'upload_max_filesize' => 10485760, - 'i18n' => array( - 'default_locale' => "en_US.UTF8", - ), ), ), $root_dir_path diff --git a/src/I18n.php b/src/I18n.php index 86a388e..6d3befc 100644 --- a/src/I18n.php +++ b/src/I18n.php @@ -44,6 +44,7 @@ class I18n { array( 'root_directory' => '${root_directory_path}/locales', 'default_locale' => null, + 'extract_messages_excluded_paths' => [], ) ); @@ -531,8 +532,11 @@ class I18n { if (Cli::core_mode() && $static_directory != Tpl::$core_static_directory) continue; if (!Cli::core_mode() && $static_directory == Tpl::$core_static_directory) continue; // List JS files to parse + $cmd = array('find', escapeshellarg(basename($static_directory)), '-name', "'*.js'"); + foreach (App::get('i18n.extract_messages_excluded_paths', null, 'array') as $path) + array_push($cmd, "-not", "-path", "./$path/*"); $result = run_external_command( - array('find', escapeshellarg(basename($static_directory)), '-name', "'*.js'"), + $cmd, null, // no STDIN data false, // do not escape command args (already done) dirname($static_directory) // Run from parent directory