Skip to content

Commit 435a145

Browse files
author
Raphaël Droz
committed
Display which template files are processed and what the final command is
1 parent a225777 commit 435a145

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Twig/Gettext/Extractor.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ protected function reset()
5757
public function addTemplate($path)
5858
{
5959
$this->environment->loadTemplate($path);
60+
if ($this->environment->isDebug()) {
61+
fprintf(STDERR, $path . PHP_EOL);
62+
}
6063
}
6164

6265
public function addGettextParameter($parameter)
@@ -76,6 +79,10 @@ public function extract()
7679
$command .= ' ' . $this->environment->getCache() . '/*/*.php';
7780

7881
$error = 0;
82+
if ($this->environment->isDebug()) {
83+
fprintf(STDERR, $command . PHP_EOL);
84+
}
85+
7986
$output = system($command, $error);
8087
if (0 !== $error) {
8188
throw new \RuntimeException(sprintf(
@@ -92,6 +99,8 @@ public function extract()
9299
public function __destruct()
93100
{
94101
$filesystem = new Filesystem();
95-
$filesystem->remove($this->environment->getCache());
102+
if (! $this->environment->isDebug()) {
103+
$filesystem->remove($this->environment->getCache());
104+
}
96105
}
97106
}

twig-gettext-extractor

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if (file_exists($a = __DIR__ . '/../../autoload.php')) {
2525
$twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem(DIRECTORY_SEPARATOR), [
2626
'cache' => implode(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), 'cache', uniqid()]),
2727
'auto_reload' => true,
28+
'debug' => getenv("DEBUG")
2829
]);
2930
$twig->addExtension(new Twig_Extensions_Extension_I18n());
3031
$twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(

0 commit comments

Comments
 (0)