From 435a1454794118f3fc5a9d56532484a70218686b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Fri, 9 Dec 2016 15:53:01 -0300 Subject: [PATCH 1/2] Display which template files are processed and what the final command is --- Twig/Gettext/Extractor.php | 11 ++++++++++- twig-gettext-extractor | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Twig/Gettext/Extractor.php b/Twig/Gettext/Extractor.php index e5247d9..634cb48 100644 --- a/Twig/Gettext/Extractor.php +++ b/Twig/Gettext/Extractor.php @@ -57,6 +57,9 @@ protected function reset() public function addTemplate($path) { $this->environment->loadTemplate($path); + if ($this->environment->isDebug()) { + fprintf(STDERR, $path . PHP_EOL); + } } public function addGettextParameter($parameter) @@ -76,6 +79,10 @@ public function extract() $command .= ' ' . $this->environment->getCache() . '/*/*.php'; $error = 0; + if ($this->environment->isDebug()) { + fprintf(STDERR, $command . PHP_EOL); + } + $output = system($command, $error); if (0 !== $error) { throw new \RuntimeException(sprintf( @@ -92,6 +99,8 @@ public function extract() public function __destruct() { $filesystem = new Filesystem(); - $filesystem->remove($this->environment->getCache()); + if (! $this->environment->isDebug()) { + $filesystem->remove($this->environment->getCache()); + } } } diff --git a/twig-gettext-extractor b/twig-gettext-extractor index 57e5c1b..f806db4 100755 --- a/twig-gettext-extractor +++ b/twig-gettext-extractor @@ -25,6 +25,7 @@ if (file_exists($a = __DIR__ . '/../../autoload.php')) { $twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem(DIRECTORY_SEPARATOR), [ 'cache' => implode(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), 'cache', uniqid()]), 'auto_reload' => true, + 'debug' => getenv("DEBUG") ]); $twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension( From 102aa51055189d92759fc4779491109717cb58bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Fri, 20 Jul 2018 15:41:58 -0300 Subject: [PATCH 2/2] use TWIG_GETTEXT_EXTRACTOR_DEBUG rather than DEBUG --- twig-gettext-extractor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twig-gettext-extractor b/twig-gettext-extractor index f806db4..4be9b59 100755 --- a/twig-gettext-extractor +++ b/twig-gettext-extractor @@ -25,7 +25,7 @@ if (file_exists($a = __DIR__ . '/../../autoload.php')) { $twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem(DIRECTORY_SEPARATOR), [ 'cache' => implode(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), 'cache', uniqid()]), 'auto_reload' => true, - 'debug' => getenv("DEBUG") + 'debug' => getenv("TWIG_GETTEXT_EXTRACTOR_DEBUG") ]); $twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(