-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display which template files are processed and what the final command is
- Loading branch information
Raphaël Droz
committed
Jul 20, 2018
1 parent
a225777
commit b153d4d
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
* | ||
|
@@ -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( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters