Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #87 from wjfz/master
Browse files Browse the repository at this point in the history
修改targetPath为Laravel 9目录结构 && 代码格式调整
  • Loading branch information
overtrue authored Apr 16, 2022
2 parents 8c7a164 + 103fd38 commit 588251b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/Commands/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
/**
* Execute the console command.
*
* @return mixed
* @return void
*/
public function handle()
{
Expand All @@ -39,10 +39,11 @@ public function handle()

$sourcePath = base_path('vendor/laravel-lang/lang/locales');
$sourceJsonPath = base_path('vendor/laravel-lang/lang/locales');
$targetPath = base_path('resources/lang/');
$targetPath = base_path('lang');

if (!is_dir($targetPath) && !mkdir($targetPath)) {
return $this->error('The lang path "resources/lang/" does not exist or not writable.');
$this->error('The lang path "lang" does not exist or not writable.');
return;
}

$files = [];
Expand Down Expand Up @@ -100,11 +101,11 @@ public function handle()
$files = implode(' ', $files);
$targetPath = escapeshellarg($targetPath);
$command = "cp -r{$force} {$files} {$targetPath}";
$process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command);
$process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process([$command]);

$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
return $this->error(trim($buffer));
$this->error(trim($buffer));
}
});

Expand Down
8 changes: 4 additions & 4 deletions src/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class FileLoader extends LaravelTranslationFileLoader
* Create a new file loader instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param array $path
* @param array $paths
* @param string $path
* @param array $paths
*/
public function __construct(Filesystem $files, $path, $paths = [])
public function __construct(Filesystem $files, string $path, array $paths = [])
{
$this->paths = $paths;

Expand Down Expand Up @@ -64,7 +64,7 @@ public function load($locale, $group, $namespace = null)
*
* @return array
*/
protected function loadPath($path, $locale, $group)
protected function loadPath($path, $locale, $group): array
{
$result = parent::loadPath($path, $locale, $group);

Expand Down
4 changes: 2 additions & 2 deletions src/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function registerLoader()

if ($this->inLumen) {
$this->app['path.lang'] = base_path('vendor/laravel/lumen-framework/resources/lang');
array_push($paths, base_path('resources/lang/'));
$paths[] = base_path('lang');
}

$loader = new FileLoader($app['files'], $app['path.lang'], $paths);
Expand All @@ -77,7 +77,7 @@ protected function registerCommands()
*
* @return array
*/
public function provides()
public function provides(): array
{
return array_merge(parent::provides(), [PublishCommand::class]);
}
Expand Down

0 comments on commit 588251b

Please sign in to comment.