diff --git a/Twig/Gettext/Extractor.php b/Twig/Gettext/Extractor.php index e5247d9..5617c77 100644 --- a/Twig/Gettext/Extractor.php +++ b/Twig/Gettext/Extractor.php @@ -13,6 +13,34 @@ use Symfony\Component\Filesystem\Filesystem; +/** + * Extracts translations from twig templates. + * + * @author Saša Stamenković + */ +class Extractor +{ + /** + * @var \Twig_Environment + */ + protected $environment; + + /** + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Twig\Gettext; + +use Symfony\Component\Filesystem\Filesystem; + /** * Extracts translations from twig templates. * @@ -57,6 +85,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 +107,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( 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(