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..4be9b59 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("TWIG_GETTEXT_EXTRACTOR_DEBUG") ]); $twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(