File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 36
36
37
37
$ consoleRoot = __DIR__ .'/../ ' ;
38
38
39
+ // Drupal installed with composer
40
+ if (is_dir (__DIR__ .'/../../../../web/ ' )) {
41
+ $ drupalRoot = __DIR__ . '/../../../../web/ ' ;
42
+ } else {
43
+ $ drupalRoot = __DIR__ . '/../../../../ ' ;
44
+ }
45
+
39
46
if (file_exists ($ consoleRoot .'vendor/autoload.php ' )) {
40
47
$ autoload = include_once $ consoleRoot .'vendor/autoload.php ' ;
41
48
} elseif (file_exists ($ consoleRoot .'../../autoload.php ' )) {
61
68
AnnotationRegistry::registerLoader ([$ autoload , "loadClass " ]);
62
69
63
70
$ config = $ container ->get ('config ' );
64
- $ container ->get ('translator ' )
65
- ->loadResource ($ config ->get ('application.language ' ), $ consoleRoot );
71
+ $ container ->get ('translator ' )->loadResource ($ config ->get ('application.language ' ), $ consoleRoot , $ drupalRoot );
66
72
67
73
$ translatorHelper = new TranslatorHelper ();
68
- $ translatorHelper ->loadResource ($ config ->get ('application.language ' ), $ consoleRoot );
74
+ $ translatorHelper ->loadResource ($ config ->get ('application.language ' ), $ consoleRoot, $ drupalRoot );
69
75
70
76
$ helpers = [
71
77
'nested-array ' => new NestedArrayHelper (),
Original file line number Diff line number Diff line change @@ -63,16 +63,21 @@ private function addLoader($loader, $name = 'yaml')
63
63
/**
64
64
* @param $language
65
65
* @param $directoryRoot
66
+ * @param $drupalRoot
66
67
*/
67
- public function loadResource ($ language , $ directoryRoot )
68
+ public function loadResource ($ language , $ directoryRoot, $ drupalRoot )
68
69
{
69
70
$ this ->language = $ language ;
70
71
$ this ->translator = new Translator ($ this ->language );
71
72
$ this ->addLoader (new ArrayLoader (), 'array ' );
72
73
$ this ->addLoader (new YamlFileLoader (), 'yaml ' );
73
74
74
- $ languageDirectory = $ directoryRoot . 'config/translations/ ' . $ language ;
75
- if (!is_dir ($ languageDirectory )) {
75
+ if ($ language != 'en ' ) {
76
+ $ languageDirectory = $ drupalRoot . 'console/language/ ' . $ language ;
77
+ if (!is_dir ($ languageDirectory )) {
78
+ $ languageDirectory = $ directoryRoot . 'config/translations/en ' ;
79
+ }
80
+ } else {
76
81
$ languageDirectory = $ directoryRoot . 'config/translations/en ' ;
77
82
}
78
83
Original file line number Diff line number Diff line change @@ -80,8 +80,9 @@ private function addLoader($loader, $name = 'yaml')
80
80
/**
81
81
* @param $language
82
82
* @param $directoryRoot
83
+ * @param $drupalRoot
83
84
*/
84
- public function loadResource ($ language , $ directoryRoot )
85
+ public function loadResource ($ language , $ directoryRoot, $ drupalRoot )
85
86
{
86
87
$ this ->language = $ language ;
87
88
$ this ->translator = new BaseTranslator ($ this ->language );
@@ -90,9 +91,15 @@ public function loadResource($language, $directoryRoot)
90
91
91
92
$ languageDirectory = $ directoryRoot . 'config/translations/ ' . $ language ;
92
93
93
- if (!is_dir ($ languageDirectory )) {
94
+ if ($ language != 'en ' ) {
95
+ $ languageDirectory = $ drupalRoot . 'console/language/ ' . $ language ;
96
+ if (!is_dir ($ languageDirectory )) {
97
+ $ languageDirectory = $ directoryRoot . 'config/translations/en ' ;
98
+ }
99
+ } else {
94
100
$ languageDirectory = $ directoryRoot . 'config/translations/en ' ;
95
101
}
102
+
96
103
$ finder = new Finder ();
97
104
$ finder ->files ()
98
105
->name ('*.yml ' )
You can’t perform that action at this time.
0 commit comments