@@ -45,6 +45,7 @@ protected function configure()
45
45
new InputOption ('domain ' , null , InputOption::VALUE_OPTIONAL , 'The messages domain ' ),
46
46
new InputOption ('only-missing ' , null , InputOption::VALUE_NONE , 'Displays only missing messages ' ),
47
47
new InputOption ('only-unused ' , null , InputOption::VALUE_NONE , 'Displays only unused messages ' ),
48
+ new InputOption ('path ' , 'p ' , InputOption::VALUE_NONE , 'Treats bundle name as path ' ),
48
49
))
49
50
->setDescription ('Displays translation messages informations ' )
50
51
->setHelp (<<<EOF
@@ -68,6 +69,10 @@ protected function configure()
68
69
69
70
<info>php %command.full_name% --only-unused en AcmeDemoBundle</info>
70
71
72
+ You can also use the command to inspect your <comment>app/</comment> directory:
73
+
74
+ <info>php %command.full_name% --path en app/</info>
75
+
71
76
EOF
72
77
)
73
78
;
@@ -80,17 +85,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
80
85
{
81
86
$ locale = $ input ->getArgument ('locale ' );
82
87
$ domain = $ input ->getOption ('domain ' );
83
- $ bundle = $ this ->getContainer ()->get ('kernel ' )->getBundle ($ input ->getArgument ('bundle ' ));
88
+
89
+ if ($ input ->getOption ('path ' )) {
90
+ $ bundlePath = $ input ->getArgument ('bundle ' );
91
+ } else {
92
+ $ bundlePath = $ this ->getContainer ()->get ('kernel ' )->getBundle ($ input ->getArgument ('bundle ' ))->getPath ();
93
+ }
84
94
$ loader = $ this ->getContainer ()->get ('translation.loader ' );
85
95
86
96
// Extract used messages
87
97
$ extractedCatalogue = new MessageCatalogue ($ locale );
88
- $ this ->getContainer ()->get ('translation.extractor ' )->extract ($ bundle -> getPath () .'/Resources/views ' , $ extractedCatalogue );
98
+ $ this ->getContainer ()->get ('translation.extractor ' )->extract ($ bundlePath .'/Resources/views ' , $ extractedCatalogue );
89
99
90
100
// Load defined messages
91
101
$ currentCatalogue = new MessageCatalogue ($ locale );
92
- if (is_dir ($ bundle -> getPath () .'/Resources/translations ' )) {
93
- $ loader ->loadMessages ($ bundle -> getPath () .'/Resources/translations ' , $ currentCatalogue );
102
+ if (is_dir ($ bundlePath .'/Resources/translations ' )) {
103
+ $ loader ->loadMessages ($ bundlePath .'/Resources/translations ' , $ currentCatalogue );
94
104
}
95
105
96
106
// Merge defined and extracted messages to get all message ids
@@ -123,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
123
133
}
124
134
125
135
$ fallbackCatalogue = new MessageCatalogue ($ fallbackLocale );
126
- $ loader ->loadMessages ($ bundle -> getPath () .'/Resources/translations ' , $ fallbackCatalogue );
136
+ $ loader ->loadMessages ($ bundlePath .'/Resources/translations ' , $ fallbackCatalogue );
127
137
$ fallbackCatalogues [] = $ fallbackCatalogue ;
128
138
}
129
139
}
0 commit comments