Skip to content

Commit a1c9c26

Browse files
committed
The 'dump' command generates files in web/js/ by default
Fix #84
1 parent 734a21c commit a1c9c26

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

Command/DumpCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
4040
parent::initialize($input, $output);
4141

4242
$this->targetPath = $input->getArgument('target') ?:
43-
realpath(sprintf('%s/../web/', $this->getContainer()->getParameter('kernel.root_dir')));
43+
realpath(sprintf('%s/../web/js', $this->getContainer()->getParameter('kernel.root_dir')));
4444
}
4545

4646
/**

Dumper/TranslationDumper.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function addLoader($id, $loader)
8989
*
9090
* @param string $target Target directory.
9191
*/
92-
public function dump($target = 'web')
92+
public function dump($target = 'web/js')
9393
{
9494
$route = $this->router->getRouteCollection()->get('bazinga_jstranslation_js');
9595
$requirements = $route->getRequirements();
@@ -108,10 +108,13 @@ public function dump($target = 'web')
108108
private function dumpConfig($route, array $formats, $target)
109109
{
110110
foreach ($formats as $format) {
111-
$file = sprintf('%s/%s', $target, strtr($route->getPattern(), array(
112-
'{domain}' => 'config',
113-
'{_format}' => $format
114-
)));
111+
$file = sprintf('%s/%s',
112+
$target,
113+
strtr($route->getPattern(), array(
114+
'{domain}' => 'config',
115+
'{_format}' => $format
116+
))
117+
);
115118

116119
$this->filesystem->mkdir(dirname($file), 0755);
117120

@@ -144,7 +147,7 @@ private function dumpTranslations($route, array $formats, $target)
144147
$file = sprintf('%s/%s',
145148
$target,
146149
strtr($route->getPattern(), array(
147-
'{domain}' => $domain . '/' . $locale,
150+
'{domain}' => sprintf('%s/%s', $domain, $locale),
148151
'{_format}' => $format
149152
))
150153
);

Resources/doc/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ This bundle provides a command to dump the translation files:
130130
php app/console bazinga:js-translation:dump [target]
131131

132132
The optional `target` argument allows you to override the target directory to
133-
dump JS translation files in.
133+
dump JS translation files in. By default, it generates files in the `web/js/`
134+
directory.
134135

135136
You have to load a `config.js` file, which contains the configuration for the
136137
JS Translator, then you can load all translation files that have been dumped.
@@ -145,14 +146,14 @@ The command above is useful if you use
145146
```twig
146147
{% javascripts
147148
'bundles/bazingajstranslation/js/translator.min.js'
148-
'translations/config.js'
149-
'translations/*/*.js' %}
149+
'js/translations/config.js'
150+
'js/translations/*/*.js' %}
150151
<script src="{{ asset_url }}"></script>
151152
{% endjavascripts %}
152153
```
153154

154155
In the example above, all translation files from your entire project will be
155-
loaded. Of course you can load specific domains: `translations/admin/*.js`.
156+
loaded. Of course you can load specific domains: `js/translations/admin/*.js`.
156157

157158
### The JS Translator
158159

Tests/Dumper/TranslationDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function setUp()
2020
$client = static::createClient();
2121
$container = $client->getContainer();
2222

23-
$this->target = sys_get_temp_dir() . '/bazinga/js-translation-bundle/';
23+
$this->target = sys_get_temp_dir() . '/bazinga/js-translation-bundle';
2424
$this->filesystem = $container->get('filesystem');
2525
$this->dumper = $container->get('bazinga.jstranslation.translation_dumper');
2626

0 commit comments

Comments
 (0)