Skip to content

Commit b153d4d

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

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Twig/Gettext/Extractor.php

+35
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@
1313

1414
use Symfony\Component\Filesystem\Filesystem;
1515

16+
/**
17+
* Extracts translations from twig templates.
18+
*
19+
* @author Saša Stamenković <[email protected]>
20+
*/
21+
class Extractor
22+
{
23+
/**
24+
* @var \Twig_Environment
25+
*/
26+
protected $environment;
27+
28+
/**
29+
<?php
30+
31+
/**
32+
* This file is part of the Twig Gettext utility.
33+
*
34+
* (c) Saša Stamenković <[email protected]>
35+
*
36+
* For the full copyright and license information, please view the LICENSE
37+
* file that was distributed with this source code.
38+
*/
39+
40+
namespace Twig\Gettext;
41+
42+
use Symfony\Component\Filesystem\Filesystem;
43+
1644
/**
1745
* Extracts translations from twig templates.
1846
*
@@ -57,6 +85,9 @@ protected function reset()
5785
public function addTemplate($path)
5886
{
5987
$this->environment->loadTemplate($path);
88+
if ($this->environment->isDebug()) {
89+
fprintf(STDERR, $path . PHP_EOL);
90+
}
6091
}
6192

6293
public function addGettextParameter($parameter)
@@ -76,6 +107,10 @@ public function extract()
76107
$command .= ' ' . $this->environment->getCache() . '/*/*.php';
77108

78109
$error = 0;
110+
if ($this->environment->isDebug()) {
111+
fprintf(STDERR, $command . PHP_EOL);
112+
}
113+
79114
$output = system($command, $error);
80115
if (0 !== $error) {
81116
throw new \RuntimeException(sprintf(

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)