blob: 6cc97c1dd306f3e959717224aaadadbbb22571b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/env php
<?php
/**
* This file is part of the Twig Gettext utility.
*
* (c) Саша Стаменковић <umpirsky@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Extracts translations from twig templates.
*
* @author Саша Стаменковић <umpirsky@gmail.com>
*/
if (file_exists($a = __DIR__.'/../../autoload.php')) {
require_once $a;
} else {
require_once __DIR__.'/vendor/autoload.php';
}
$twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem('/'), array(
'cache' => '/tmp/cache/'.uniqid(),
'auto_reload' => true
));
$twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(
new Symfony\Component\Translation\Translator(null)
));
$twig->addExtension(new Twig_Extensions_Extension_I18n());
$twig->addExtension(new Symfony\Bridge\Twig\Extension\RoutingExtension(
new Twig\Gettext\Routing\Generator\UrlGenerator()
));
$twig->addExtension(new Symfony\Bridge\Twig\Extension\FormExtension(
new Symfony\Bridge\Twig\Form\TwigRenderer(
new Symfony\Bridge\Twig\Form\TwigRendererEngine()
)
));
// You can add more extensions here.
array_shift($_SERVER['argv']);
$addTemplate = false;
$extractor = new Twig\Gettext\Extractor($twig);
foreach ($_SERVER['argv'] as $arg) {
if ('--files' == $arg) {
$addTemplate = true;
} else if ($addTemplate) {
$extractor->addTemplate(getcwd().DIRECTORY_SEPARATOR.$arg);
} else {
$extractor->addGettextParameter($arg);
}
}
$extractor->extract();
|