@@ -71,9 +71,8 @@ function () use ($directory, $plugins) {
71
71
/** @var Plugin $plugin */
72
72
foreach ($ plugins as $ plugin ) {
73
73
$ this ->collectKeys ($ directory , $ plugin ->files ());
74
+ $ this ->collectLocalizations ($ directory , $ plugin ->files ());
74
75
}
75
-
76
- $ this ->collectLocalizations ($ directory );
77
76
}
78
77
);
79
78
}
@@ -109,28 +108,34 @@ protected function collectKeys(string $directory, array $files): void
109
108
foreach ($ files as $ source => $ target ) {
110
109
$ values = $ this ->filesystem ->load ($ directory . '/source/ ' . $ source );
111
110
112
- $ this ->translation ->setSource ($ directory , $ target , $ values );
111
+ $ this ->translation ->setSource ($ target , $ values );
113
112
}
114
113
}
115
114
116
- protected function collectLocalizations (string $ directory ): void
115
+ protected function collectLocalizations (string $ directory, array $ files ): void
117
116
{
118
- foreach ($ this -> locales as $ locale ) {
119
- $ locale = $ this ->fromAlias ( $ locale ?->value ?? $ locale );
117
+ foreach ($ files as $ filename ) {
118
+ $ keys = array_keys ( $ this ->translation -> getSource ( $ filename ) );
120
119
121
- $ locale_alias = $ this ->toAlias ($ locale );
120
+ foreach ($ this ->locales as $ locale ) {
121
+ $ locale = $ this ->fromAlias ($ locale ?->value ?? $ locale );
122
122
123
- foreach ($ this ->file_types as $ type ) {
124
- $ main_path = $ this ->localeFilename ($ locale_alias , "$ directory/locales/ $ locale/ $ type.json " );
125
- $ inline_path = $ this ->localeFilename ($ locale_alias , "$ directory/locales/ $ locale/ $ type.json " , true );
123
+ $ locale_alias = $ this ->toAlias ($ locale );
126
124
127
- $ values = $ this ->filesystem ->load ($ main_path );
125
+ foreach ($ this ->file_types as $ type ) {
126
+ $ main_path = $ this ->localeFilename ($ locale_alias , "$ directory/locales/ $ locale/ $ type.json " );
127
+ $ inline_path = $ this ->localeFilename ($ locale_alias , "$ directory/locales/ $ locale/ $ type.json " , true );
128
128
129
- if ($ main_path !== $ inline_path && $ this ->config ->hasInline ()) {
130
- $ values = $ this ->arr ->merge ($ values , $ this ->filesystem ->load ($ inline_path ));
131
- }
129
+ $ values = $ this ->filesystem ->load ($ main_path );
130
+
131
+ if ($ main_path !== $ inline_path && $ this ->config ->hasInline ()) {
132
+ $ values = $ this ->arr ->merge ($ values , $ this ->filesystem ->load ($ inline_path ));
133
+ }
134
+
135
+ $ values = collect ($ values )->only ($ keys )->toArray ();
132
136
133
- $ this ->translation ->setTranslations ($ directory , $ locale_alias , $ values );
137
+ $ this ->translation ->setTranslations ($ filename , $ locale_alias , $ values );
138
+ }
134
139
}
135
140
}
136
141
}
0 commit comments