5 * This file is part of the Twig Gettext utility.
7 * (c) Саша Стаменковић <umpirsky@gmail.com>
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
14 * Extracts translations from twig templates.
16 * @author Саша Стаменковић <umpirsky@gmail.com>
19 if (file_exists($a = __DIR__
.'/../../autoload.php')) {
22 require_once __DIR__
.'/vendor/autoload.php';
25 $twig = new Twig_Environment(new Twig\Gettext\Loader\
Filesystem('/'), array(
26 'cache' => '/tmp/cache/'.uniqid(),
29 $twig->addExtension(new Symfony\Bridge\Twig\Extension\
TranslationExtension(
30 new Symfony\Component\Translation\
Translator(null)
32 $twig->addExtension(new Twig_Extensions_Extension_I18n());
33 $twig->addExtension(new Symfony\Bridge\Twig\Extension\
RoutingExtension(
34 new Twig\Gettext\Routing\Generator\
UrlGenerator()
36 $twig->addExtension(new Symfony\Bridge\Twig\Extension\
FormExtension(
37 new Symfony\Bridge\Twig\Form\
TwigRenderer(
38 new Symfony\Bridge\Twig\Form\
TwigRendererEngine()
41 // You can add more extensions here.
43 array_shift($_SERVER['argv']);
46 $extractor = new Twig\Gettext\
Extractor($twig);
48 foreach ($_SERVER['argv'] as $arg) {
49 if ('--files' == $arg) {
51 } else if ($addTemplate) {
52 $extractor->addTemplate(getcwd().DIRECTORY_SEPARATOR
.$arg);
54 $extractor->addGettextParameter($arg);
58 $extractor->extract();