Skip to content

Commit

Permalink
Update to Support Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
askdkc committed Jan 17, 2024
1 parent 0bd3145 commit a6d3f96
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions src/Commands/BreezejpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,55 @@ public function handle(): int
(new Filesystem)->ensureDirectoryExists(lang_path());
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/lang/', lang_path());

$this->info('config/app.phpのlocaleをjaにします');
$envfile = file_get_contents(base_path('.env'));

if (strpos($envfile, 'APP_FAKER_LOCALE') == false) {
$this->info('config/app.phpのlocaleをjaにします');
// Read the contents of the file into a string
$configfile = file_get_contents(base_path('config/app.php'));

// Modify the contents of the string
$configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile);
$configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile);
$configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile);

// Save the modified contents back to the file
file_put_contents(base_path('config/app.php'), $configfile);

if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) {
$repoUrl = 'https://github.com/askdkc/breezejp';

if (PHP_OS_FAMILY == 'Darwin') {
exec("open {$repoUrl}");
}
if (PHP_OS_FAMILY == 'Windows') {
exec("start {$repoUrl}");
}
if (PHP_OS_FAMILY == 'Linux') {
exec("xdg-open {$repoUrl}");
}

$this->line('Thank you! / ありがとう💓');
}

$this->info('日本語ファイルのインストールが完了しました!');

return self::SUCCESS;

}

// For Laravel 11 and above
$this->info('.envのAPP_LOCALEやAPP_TIMEZONEを日本にします');
// Read the contents of the file into a string
$configfile = file_get_contents(base_path('config/app.php'));
$configfile = file_get_contents(base_path('.env'));

// Modify the contents of the string
$configfile = str_replace("'locale' => 'en'", "'locale' => 'ja'", $configfile);
$configfile = str_replace("'faker_locale' => 'en_US'", "'faker_locale' => 'ja_JP'", $configfile);
$configfile = str_replace("'timezone' => 'UTC'", "'timezone' => 'Asia/Tokyo'", $configfile);
$configfile = str_replace('APP_LOCALE=en', 'APP_LOCALE=ja', $configfile);
$configfile = str_replace('APP_FAKER_LOCALE=en_US', 'APP_FAKER_LOCALE=ja_JP', $configfile);
$configfile = str_replace('APP_TIMEZONE=UTC', 'APP_TIMEZONE=Asia/Tokyo', $configfile);

// Save the modified contents back to the file
file_put_contents(base_path('config/app.php'), $configfile);
file_put_contents(base_path('.env'), $configfile);

if ($this->confirm('GitHubリポジトリにスターの御協力をお願いします🙏', true)) {
$repoUrl = 'https://github.com/askdkc/breezejp';
Expand All @@ -56,5 +94,6 @@ public function handle(): int
$this->info('日本語ファイルのインストールが完了しました!');

return self::SUCCESS;

}
}

0 comments on commit a6d3f96

Please sign in to comment.