aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/umpirsky/twig-gettext-extractor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/umpirsky/twig-gettext-extractor')
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/.gitignore3
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/.travis.yml10
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/LICENSE19
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/README.md49
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php95
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Loader/Filesystem.php58
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Routing/Generator/UrlGenerator.php39
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/ExtractorTest.php123
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/empty.twig1
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/plural.twig5
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/singular.twig9
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/composer.json30
-rw-r--r--vendor/umpirsky/twig-gettext-extractor/phpunit.xml.dist14
-rwxr-xr-xvendor/umpirsky/twig-gettext-extractor/twig-gettext-extractor58
14 files changed, 0 insertions, 513 deletions
diff --git a/vendor/umpirsky/twig-gettext-extractor/.gitignore b/vendor/umpirsky/twig-gettext-extractor/.gitignore
deleted file mode 100644
index 61381e45..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
1vendor
2phpunit.xml
3composer.lock
diff --git a/vendor/umpirsky/twig-gettext-extractor/.travis.yml b/vendor/umpirsky/twig-gettext-extractor/.travis.yml
deleted file mode 100644
index 0c9bce01..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/.travis.yml
+++ /dev/null
@@ -1,10 +0,0 @@
1language: php
2
3before_script:
4 - curl -s http://getcomposer.org/installer | php
5 - php composer.phar install --dev
6
7php:
8 - 5.3
9 - 5.4
10
diff --git a/vendor/umpirsky/twig-gettext-extractor/LICENSE b/vendor/umpirsky/twig-gettext-extractor/LICENSE
deleted file mode 100644
index df9dd107..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
1Copyright (c) Саша Стаменковић <umpirsky@gmail.com>
2
3Permission is hereby granted, free of charge, to any person obtaining a copy
4of this software and associated documentation files (the "Software"), to deal
5in the Software without restriction, including without limitation the rights
6to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7copies of the Software, and to permit persons to whom the Software is furnished
8to do so, subject to the following conditions:
9
10The above copyright notice and this permission notice shall be included in all
11copies or substantial portions of the Software.
12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19THE SOFTWARE. \ No newline at end of file
diff --git a/vendor/umpirsky/twig-gettext-extractor/README.md b/vendor/umpirsky/twig-gettext-extractor/README.md
deleted file mode 100644
index 34eff88c..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
1Twig Gettext Extractor [![Build Status](https://secure.travis-ci.org/umpirsky/Twig-Gettext-Extractor.png?branch=master)](http://travis-ci.org/umpirsky/Twig-Gettext-Extractor)
2======================
3
4The Twig Gettext Extractor is [Poedit](http://www.poedit.net/download.php)
5friendly tool which extracts translations from twig templates.
6
7## Installation
8
9The recommended way to install Twig Gettext Extractor is through
10[composer](http://getcomposer.org).
11
12```json
13{
14 "require": {
15 "umpirsky/twig-gettext-extractor": "1.1.*"
16 }
17}
18```
19
20## Setup
21
22By default, Poedit does not have the ability to parse Twig templates.
23This can be resolved by adding an additional parser (Edit > Preferences > Parsers)
24with the following options:
25
26- Language: `Twig`
27- List of extensions: `*.twig`
28- Invocation:
29 - Parser command: `<project>/vendor/bin/twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --files %F`
30 - An item in keyword list: `-k%k`
31 - An item in input file list: `%f`
32 - Source code charset: `--from-code=%c`
33
34<img src="http://i.imgur.com/f9px2.png" />
35
36Now you can update your catalog and Poedit will synchronize it with your twig
37templates.
38
39## Tests
40
41To run the test suite, you need [composer](http://getcomposer.org) and
42[PHPUnit](https://github.com/sebastianbergmann/phpunit).
43
44 $ composer install --dev
45 $ phpunit
46
47## License
48
49Twig Gettext Extractor is licensed under the MIT license.
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php
deleted file mode 100644
index e7fa1af2..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php
+++ /dev/null
@@ -1,95 +0,0 @@
1<?php
2
3/**
4 * This file is part of the Twig Gettext utility.
5 *
6 * (c) Саша Стаменковић <umpirsky@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\Gettext;
13
14use Symfony\Component\Filesystem\Filesystem;
15
16/**
17 * Extracts translations from twig templates.
18 *
19 * @author Саша Стаменковић <umpirsky@gmail.com>
20 */
21class Extractor
22{
23 /**
24 * @var \Twig_Environment
25 */
26 protected $environment;
27
28 /**
29 * Template cached file names.
30 *
31 * @var string[]
32 */
33 protected $templates;
34
35 /**
36 * Gettext parameters.
37 *
38 * @var string[]
39 */
40 protected $parameters;
41
42 public function __construct(\Twig_Environment $environment)
43 {
44 $this->environment = $environment;
45 $this->reset();
46 }
47
48 protected function reset()
49 {
50 $this->templates = array();
51 $this->parameters = array();
52 }
53
54 public function addTemplate($path)
55 {
56 $this->environment->loadTemplate($path);
57 $this->templates[] = $this->environment->getCacheFilename($path);
58 }
59
60 public function addGettextParameter($parameter)
61 {
62 $this->parameters[] = $parameter;
63 }
64
65 public function setGettextParameters(array $parameters)
66 {
67 $this->parameters = $parameters;
68 }
69
70 public function extract()
71 {
72 $command = 'xgettext';
73 $command .= ' '.join(' ', $this->parameters);
74 $command .= ' '.join(' ', $this->templates);
75
76 $error = 0;
77 $output = system($command, $error);
78 if (0 !== $error) {
79 throw new \RuntimeException(sprintf(
80 'Gettext command "%s" failed with error code %s and output: %s',
81 $command,
82 $error,
83 $output
84 ));
85 }
86
87 $this->reset();
88 }
89
90 public function __destruct()
91 {
92 $filesystem = new Filesystem();
93 $filesystem->remove($this->environment->getCache());
94 }
95}
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Loader/Filesystem.php b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Loader/Filesystem.php
deleted file mode 100644
index b011b032..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Loader/Filesystem.php
+++ /dev/null
@@ -1,58 +0,0 @@
1<?php
2
3/**
4 * This file is part of the Twig Gettext utility.
5 *
6 * (c) Саша Стаменковић <umpirsky@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\Gettext\Loader;
13
14/**
15 * Loads template from the filesystem.
16 *
17 * @author Саша Стаменковић <umpirsky@gmail.com>
18 */
19class Filesystem extends \Twig_Loader_Filesystem
20{
21 /**
22 * Hacked find template to allow loading templates by absolute path.
23 *
24 * @param string $name template name or absolute path
25 */
26 protected function findTemplate($name)
27 {
28 // normalize name
29 $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));
30
31 if (isset($this->cache[$name])) {
32 return $this->cache[$name];
33 }
34
35 $this->validateName($name);
36
37 $namespace = '__main__';
38 if (isset($name[0]) && '@' == $name[0]) {
39 if (false === $pos = strpos($name, '/')) {
40 throw new \InvalidArgumentException(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
41 }
42
43 $namespace = substr($name, 1, $pos - 1);
44
45 $name = substr($name, $pos + 1);
46 }
47
48 if (!isset($this->paths[$namespace])) {
49 throw new \Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace));
50 }
51
52 if (is_file($name)) {
53 return $this->cache[$name] = $name;
54 }
55
56 return __DIR__.'/../Test/Fixtures/twig/empty.twig';
57 }
58}
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Routing/Generator/UrlGenerator.php b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Routing/Generator/UrlGenerator.php
deleted file mode 100644
index 9e3431bd..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Routing/Generator/UrlGenerator.php
+++ /dev/null
@@ -1,39 +0,0 @@
1<?php
2
3/**
4 * This file is part of the Twig Gettext utility.
5 *
6 * (c) Саша Стаменковић <umpirsky@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\Gettext\Routing\Generator;
13
14use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
15use Symfony\Component\Routing\RequestContext;
16
17/**
18 * Dummy url generator.
19 *
20 * @author Саша Стаменковић <umpirsky@gmail.com>
21 */
22class UrlGenerator implements UrlGeneratorInterface
23{
24 protected $context;
25
26 public function generate($name, $parameters = array(), $absolute = false)
27 {
28 }
29
30 public function getContext()
31 {
32 return $this->context;
33 }
34
35 public function setContext(RequestContext $context)
36 {
37 $this->context = $context;
38 }
39}
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/ExtractorTest.php b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/ExtractorTest.php
deleted file mode 100644
index d467835f..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/ExtractorTest.php
+++ /dev/null
@@ -1,123 +0,0 @@
1<?php
2
3/**
4 * This file is part of the Twig Gettext utility.
5 *
6 * (c) Саша Стаменковић <umpirsky@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\Gettext\Test;
13
14use Twig\Gettext\Extractor;
15use Twig\Gettext\Loader\Filesystem;
16use Symfony\Component\Translation\Loader\PoFileLoader;
17
18/**
19 * @author Саша Стаменковић <umpirsky@gmail.com>
20 */
21class ExtractorTest extends \PHPUnit_Framework_TestCase
22{
23 /**
24 * @var \Twig_Environment
25 */
26 protected $twig;
27
28 /**
29 * @var PoFileLoader
30 */
31 protected $loader;
32
33 protected function setUp()
34 {
35 $this->twig = new \Twig_Environment(new Filesystem('/'), array(
36 'cache' => '/tmp/cache/'.uniqid(),
37 'auto_reload' => true
38 ));
39 $this->twig->addExtension(new \Twig_Extensions_Extension_I18n());
40
41 $this->loader = new PoFileLoader();
42 }
43
44 /**
45 * @dataProvider testExtractDataProvider
46 */
47 public function testExtract(array $templates, array $parameters, array $messages)
48 {
49 $extractor = new Extractor($this->twig);
50
51 foreach ($templates as $template) {
52 $extractor->addTemplate($template);
53 }
54 foreach ($parameters as $parameter) {
55 $extractor->addGettextParameter($parameter);
56 }
57
58 $extractor->extract();
59
60 $catalog = $this->loader->load($this->getPotFile(), null);
61
62 foreach ($messages as $message) {
63 $this->assertTrue(
64 $catalog->has($message),
65 sprintf('Message "%s" not found in catalog.', $message)
66 );
67 }
68 }
69
70 public function testExtractDataProvider()
71 {
72 return array(
73 array(
74 array(
75 __DIR__.'/Fixtures/twig/singular.twig',
76 __DIR__.'/Fixtures/twig/plural.twig',
77 ),
78 $this->getGettextParameters(),
79 array(
80 'Hello %name%!',
81 'Hello World!',
82 'Hey %name%, I have one apple.',
83 'Hey %name%, I have %count% apples.',
84 ),
85 ),
86 );
87 }
88
89 public function testExtractNoTranslations()
90 {
91 $extractor = new Extractor($this->twig);
92
93 $extractor->addTemplate(__DIR__.'/Fixtures/twig/empty.twig');
94 $extractor->setGettextParameters($this->getGettextParameters());
95
96 $extractor->extract();
97
98 $catalog = $this->loader->load($this->getPotFile(), null);
99
100 $this->assertEmpty($catalog->all('messages'));
101 }
102
103 private function getPotFile()
104 {
105 return __DIR__.'/Fixtures/messages.pot';
106 }
107
108 private function getGettextParameters()
109 {
110 return array(
111 '--force-po',
112 '-o',
113 $this->getPotFile(),
114 );
115 }
116
117 protected function tearDown()
118 {
119 if (file_exists($this->getPotFile())) {
120 unlink($this->getPotFile());
121 }
122 }
123}
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/empty.twig b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/empty.twig
deleted file mode 100644
index 05f0d26a..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/empty.twig
+++ /dev/null
@@ -1 +0,0 @@
1Nothing to translate here.
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/plural.twig b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/plural.twig
deleted file mode 100644
index f9754ff4..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/plural.twig
+++ /dev/null
@@ -1,5 +0,0 @@
1{% trans %}
2 Hey {{ name }}, I have one apple.
3{% plural apple_count %}
4 Hey {{ name }}, I have {{ count }} apples.
5{% endtrans %}
diff --git a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/singular.twig b/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/singular.twig
deleted file mode 100644
index d757cf90..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Test/Fixtures/twig/singular.twig
+++ /dev/null
@@ -1,9 +0,0 @@
1{% trans "Hello World!" %}
2
3{% trans %}
4 Hello World!
5{% endtrans %}
6
7{% trans %}
8 Hello {{ name }}!
9{% endtrans %}
diff --git a/vendor/umpirsky/twig-gettext-extractor/composer.json b/vendor/umpirsky/twig-gettext-extractor/composer.json
deleted file mode 100644
index 7cda5f73..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/composer.json
+++ /dev/null
@@ -1,30 +0,0 @@
1{
2 "name": "umpirsky/twig-gettext-extractor",
3 "type": "application",
4 "description": "The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.",
5 "license": "MIT",
6 "authors": [
7 {
8 "name": "Саша Стаменковић",
9 "email": "umpirsky@gmail.com"
10 }
11 ],
12 "require": {
13 "php": ">=5.3.3",
14 "twig/twig": ">=1.2.0,<2.0-dev",
15 "twig/extensions": "1.0.*",
16 "symfony/twig-bridge": ">=2.0,<3.0",
17 "symfony/routing": ">=2.0,<3.0",
18 "symfony/filesystem": ">=2.0,<3.0",
19 "symfony/translation": ">=2.0,<3.0",
20 "symfony/form": ">=2.0,<3.0"
21 },
22 "require-dev": {
23 "symfony/config": "2.1.*"
24 },
25 "minimum-stability": "dev",
26 "autoload": {
27 "psr-0": { "Twig\\Gettext": "." }
28 },
29 "bin": ["twig-gettext-extractor"]
30} \ No newline at end of file
diff --git a/vendor/umpirsky/twig-gettext-extractor/phpunit.xml.dist b/vendor/umpirsky/twig-gettext-extractor/phpunit.xml.dist
deleted file mode 100644
index 56fdc6b0..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/phpunit.xml.dist
+++ /dev/null
@@ -1,14 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2
3<phpunit colors="true"
4 convertErrorsToExceptions="true"
5 convertNoticesToExceptions="true"
6 convertWarningsToExceptions="true"
7 bootstrap="./vendor/autoload.php"
8>
9 <testsuites>
10 <testsuite name="Twig Gettext Extractor Test Suite">
11 <directory>./Twig/Gettext/Test/</directory>
12 </testsuite>
13 </testsuites>
14</phpunit>
diff --git a/vendor/umpirsky/twig-gettext-extractor/twig-gettext-extractor b/vendor/umpirsky/twig-gettext-extractor/twig-gettext-extractor
deleted file mode 100755
index 6cc97c1d..00000000
--- a/vendor/umpirsky/twig-gettext-extractor/twig-gettext-extractor
+++ /dev/null
@@ -1,58 +0,0 @@
1#!/usr/bin/env php
2<?php
3
4/**
5 * This file is part of the Twig Gettext utility.
6 *
7 * (c) Саша Стаменковић <umpirsky@gmail.com>
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13/**
14 * Extracts translations from twig templates.
15 *
16 * @author Саша Стаменковић <umpirsky@gmail.com>
17 */
18
19if (file_exists($a = __DIR__.'/../../autoload.php')) {
20 require_once $a;
21} else {
22 require_once __DIR__.'/vendor/autoload.php';
23}
24
25$twig = new Twig_Environment(new Twig\Gettext\Loader\Filesystem('/'), array(
26 'cache' => '/tmp/cache/'.uniqid(),
27 'auto_reload' => true
28));
29$twig->addExtension(new Symfony\Bridge\Twig\Extension\TranslationExtension(
30 new Symfony\Component\Translation\Translator(null)
31));
32$twig->addExtension(new Twig_Extensions_Extension_I18n());
33$twig->addExtension(new Symfony\Bridge\Twig\Extension\RoutingExtension(
34 new Twig\Gettext\Routing\Generator\UrlGenerator()
35));
36$twig->addExtension(new Symfony\Bridge\Twig\Extension\FormExtension(
37 new Symfony\Bridge\Twig\Form\TwigRenderer(
38 new Symfony\Bridge\Twig\Form\TwigRendererEngine()
39 )
40));
41// You can add more extensions here.
42
43array_shift($_SERVER['argv']);
44$addTemplate = false;
45
46$extractor = new Twig\Gettext\Extractor($twig);
47
48foreach ($_SERVER['argv'] as $arg) {
49 if ('--files' == $arg) {
50 $addTemplate = true;
51 } else if ($addTemplate) {
52 $extractor->addTemplate(getcwd().DIRECTORY_SEPARATOR.$arg);
53 } else {
54 $extractor->addGettextParameter($arg);
55 }
56}
57
58$extractor->extract();