Skip to content

Commit

Permalink
Display which template files are processed and what the final command is
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Droz committed Jul 20, 2018
1 parent a225777 commit b153d4d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Twig/Gettext/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@

use Symfony\Component\Filesystem\Filesystem;

/**
* Extracts translations from twig templates.
*
* @author Saša Stamenković <[email protected]>
*/
class Extractor
{
/**
* @var \Twig_Environment
*/
protected $environment;

/**
<?php
/**
* This file is part of the Twig Gettext utility.
*
* (c) Saša Stamenković <[email protected]>
*
* 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.
*
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down
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")
]);
$twig->addExtension(new Twig_Extensions_Extension_I18n());
$twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(
Expand Down

0 comments on commit b153d4d

Please sign in to comment.