1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @namespace Asm\TranslationLoaderBundle\Command |
4
|
|
|
*/ |
5
|
|
|
namespace Asm\TranslationLoaderBundle\Command; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class DumpTranslationFiles |
12
|
|
|
* |
13
|
|
|
* @package Asm\TranslationLoaderBundle\Command |
14
|
|
|
* @author marc aschmann <[email protected]> |
15
|
|
|
* @uses Symfony\Component\Console\Input\InputArgument |
16
|
|
|
* @uses Symfony\Component\Console\Input\InputInterface |
17
|
|
|
* @uses Symfony\Component\Console\Input\InputOption |
18
|
|
|
* @uses Symfony\Component\Console\Output\OutputInterface |
19
|
|
|
*/ |
20
|
|
|
class GenerateDummyFilesCommand extends BaseTranslationCommand |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* command configuration |
24
|
|
|
*/ |
25
|
6 |
|
protected function configure() |
26
|
|
|
{ |
27
|
6 |
|
$this |
28
|
6 |
|
->setName('asm:translations:dummy') |
29
|
6 |
|
->setDescription('generate dummy files for translation loader'); |
30
|
6 |
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param InputInterface $input |
35
|
|
|
* @param OutputInterface $output |
36
|
|
|
* @return int|null|void |
37
|
|
|
*/ |
38
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
39
|
|
|
{ |
40
|
1 |
|
$output->writeln( |
41
|
|
|
'<info>--------------------------------------------------------------------------------</info>' |
42
|
1 |
|
); |
43
|
1 |
|
$output->writeln('<info>generating dummy files</info>'); |
44
|
1 |
|
$output->writeln( |
45
|
|
|
'<info>--------------------------------------------------------------------------------</info>' |
46
|
1 |
|
); |
47
|
|
|
|
48
|
1 |
|
$translationPath = $this->getKernel()->getRootDir() . '/Resources/translations/'; |
49
|
1 |
|
$fs = $this->getFilesystem(); |
50
|
|
|
|
51
|
|
|
// create directory for translations if not exists |
52
|
1 |
|
if (!$fs->exists($translationPath)) { |
53
|
1 |
|
$fs->mkdir($translationPath); |
54
|
1 |
|
} |
55
|
|
|
|
56
|
1 |
|
$translationManager = $this->getTranslationManager(); |
57
|
1 |
|
$translations = $translationManager->findAllTranslations(); |
58
|
|
|
|
59
|
1 |
|
foreach ($translations as $translation) { |
60
|
1 |
|
$filename = $translation->getMessageDomain() . '.' . $translation->getTransLocale() . '.db'; |
61
|
|
|
|
62
|
1 |
|
if (!$fs->exists($translationPath . $filename)) { |
63
|
1 |
|
$fs->touch($translationPath . $filename); |
64
|
1 |
|
} |
65
|
1 |
|
} |
66
|
|
|
|
67
|
1 |
|
$output->writeln( |
68
|
|
|
'<info>--------------------------------------------------------------------------------</info>' |
69
|
1 |
|
); |
70
|
1 |
|
$output->writeln('<info>finished!</info>'); |
71
|
1 |
|
$output->writeln( |
72
|
|
|
'<info>--------------------------------------------------------------------------------</info>' |
73
|
1 |
|
); |
74
|
1 |
|
} |
75
|
|
|
} |
76
|
|
|
|