Skip to content

Commit a1cbc8b

Browse files
sporchiamartinlindhe
authored andcommitted
Relative translations are not loaded in the proper locale (martinlindhe#54)
* Relative translations are not loaded in the proper locale e.g. if you have a file: ```PHP <?php return [ ‘key’ => __(‘other_file.other_key’), ]; ``` it is translated to the base locale and not the current locale, this should fix that. * updated so tests don't fail since the unit tests aren’t run inside of Laravel scope, this will check that App is available before calling setLocale on it.
1 parent 32dc7f8 commit a1cbc8b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Generator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function generateFromPath($path, $umd = null, $withVendor = false)
5959
$fileinfo = new \SplFileInfo($fileName);
6060

6161
$noExt = $this->removeExtension($fileinfo->getFilename());
62+
if (class_exists('App')) {
63+
App::setLocale($noExt);
64+
}
6265

6366
if ($fileinfo->isDir()) {
6467
$local = $this->allocateLocaleArray($fileinfo->getRealPath());
@@ -113,8 +116,10 @@ public function generateMultiple($path, $umd = null)
113116
&& !in_array($fileinfo->getFilename(), ['vendor'])
114117
) {
115118
$noExt = $this->removeExtension($fileinfo->getFilename());
116-
if (!in_array($noExt, $this->availableLocales)) {
119+
if (class_exists('App')) {
117120
App::setLocale($noExt);
121+
}
122+
if (!in_array($noExt, $this->availableLocales)) {
118123
$this->availableLocales[] = $noExt;
119124
}
120125
if ($fileinfo->isDir()) {

0 commit comments

Comments
 (0)