From c5c15f686da760f63275a5d6e3a1893935158f4c Mon Sep 17 00:00:00 2001 From: nicolasbeauvais Date: Mon, 9 Oct 2017 23:58:54 +0200 Subject: [PATCH 1/2] Remove unused use statement --- src/Commands/FindCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Commands/FindCommand.php b/src/Commands/FindCommand.php index 73cad05..9c5577b 100644 --- a/src/Commands/FindCommand.php +++ b/src/Commands/FindCommand.php @@ -5,7 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Support\Arr; use Themsaid\Langman\Manager; -use Illuminate\Support\Str; class FindCommand extends Command { From c58806647b46a7dffd4e04b9dcb3808b306321e4 Mon Sep 17 00:00:00 2001 From: nicolasbeauvais Date: Tue, 10 Oct 2017 00:00:07 +0200 Subject: [PATCH 2/2] Make langman works with subdirectories --- src/Manager.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Manager.php b/src/Manager.php index 4ff5824..f02a078 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -58,20 +58,21 @@ public function files() }); $filesByFile = $files->groupBy(function ($file) { - $fileName = $file->getBasename('.'.$file->getExtension()); + $filePath = str_replace('.' . $file->getExtension(), '', $file->getRelativePathname()); + $filePath = array_reverse(explode('/', $filePath, 2))[0]; if (Str::contains($file->getPath(), 'vendor')) { - $fileName = str_replace('.php', '', $file->getFileName()); + $filePath = str_replace('.php', '', $file->getFileName()); $packageName = basename(dirname($file->getPath())); - return "{$packageName}::{$fileName}"; + return "{$packageName}::{$filePath}"; } else { - return $fileName; + return $filePath; } })->map(function ($files) { return $files->keyBy(function ($file) { - return basename($file->getPath()); + return explode('/', str_replace($this->path, '', $file->getRelativePathname()))[0]; })->map(function ($file) { return $file->getRealPath(); });