Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display which template files are processed and what the final command is #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Twig/Gettext/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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());
}
}
}
1 change: 1 addition & 0 deletions twig-gettext-extractor
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use 'debug' => getenv('TWIG_GETTEXT_EXTRACTOR_DEBUG') here.

]);
$twig->addExtension(new Twig_Extensions_Extension_I18n());
$twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(
Expand Down