@@ -61,6 +61,8 @@ protected function configure()
61
61
*/
62
62
protected function execute (InputInterface $ input , OutputInterface $ output )
63
63
{
64
+ $ kernel = $ this ->getContainer ()->get ('kernel ' );
65
+
64
66
// check presence of force or dump-message
65
67
if ($ input ->getOption ('force ' ) !== true && $ input ->getOption ('dump-messages ' ) !== true ) {
66
68
$ output ->writeln ('<info>You must choose one of --force or --dump-messages</info> ' );
@@ -79,22 +81,36 @@ protected function execute(InputInterface $input, OutputInterface $output)
79
81
}
80
82
81
83
// get bundle directory
82
- $ foundBundle = $ this ->getApplication ()->getKernel ()->getBundle ($ input ->getArgument ('bundle ' ));
83
- $ bundleTransPath = $ foundBundle ->getPath ().'/Resources/translations ' ;
84
+ $ foundBundle = $ kernel ->getBundle ($ input ->getArgument ('bundle ' ));
85
+ $ bundleTransPaths = array (
86
+ $ foundBundle ->getPath ().'/Resources/ ' ,
87
+ sprintf ('%s/Resources/%s/ ' , $ kernel ->getRootDir (), $ foundBundle ->getName ()),
88
+ );
89
+
84
90
$ output ->writeln (sprintf ('Generating "<info>%s</info>" translation files for "<info>%s</info>" ' , $ input ->getArgument ('locale ' ), $ foundBundle ->getName ()));
85
91
86
92
// load any messages from templates
87
93
$ extractedCatalogue = new MessageCatalogue ($ input ->getArgument ('locale ' ));
88
94
$ output ->writeln ('Parsing templates ' );
89
95
$ extractor = $ this ->getContainer ()->get ('translation.extractor ' );
90
96
$ extractor ->setPrefix ($ input ->getOption ('prefix ' ));
91
- $ extractor ->extract ($ foundBundle ->getPath ().'/Resources/views/ ' , $ extractedCatalogue );
97
+ foreach ($ bundleTransPaths as $ path ) {
98
+ $ path = $ path .'views ' ;
99
+ if (is_dir ($ path )) {
100
+ $ extractor ->extract ($ path , $ extractedCatalogue );
101
+ }
102
+ }
92
103
93
104
// load any existing messages from the translation files
94
105
$ currentCatalogue = new MessageCatalogue ($ input ->getArgument ('locale ' ));
95
106
$ output ->writeln ('Loading translation files ' );
96
107
$ loader = $ this ->getContainer ()->get ('translation.loader ' );
97
- $ loader ->loadMessages ($ bundleTransPath , $ currentCatalogue );
108
+ foreach ($ bundleTransPaths as $ path ) {
109
+ $ path = $ path .'translations ' ;
110
+ if (is_dir ($ path )) {
111
+ $ loader ->loadMessages ($ path , $ currentCatalogue );
112
+ }
113
+ }
98
114
99
115
// process catalogues
100
116
$ operation = $ input ->getOption ('clean ' )
@@ -133,7 +149,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
133
149
// save the files
134
150
if ($ input ->getOption ('force ' ) === true ) {
135
151
$ output ->writeln ('Writing files ' );
136
- $ writer ->writeTranslations ($ operation ->getResult (), $ input ->getOption ('output-format ' ), array ('path ' => $ bundleTransPath ));
152
+ $ bundleTransPath = false ;
153
+ foreach ($ bundleTransPaths as $ path ) {
154
+ $ path = $ path .'translations ' ;
155
+ if (is_dir ($ path )) {
156
+ $ bundleTransPath = $ path ;
157
+ }
158
+ }
159
+
160
+ if ($ bundleTransPath ) {
161
+ $ writer ->writeTranslations ($ operation ->getResult (), $ input ->getOption ('output-format ' ), array ('path ' => $ bundleTransPath ));
162
+ }
137
163
}
138
164
}
139
165
}
0 commit comments