From 594456af10bdafbad8889134c8f813c29e7ad20f Mon Sep 17 00:00:00 2001 From: askdkc Date: Wed, 17 Jan 2024 10:26:38 +0900 Subject: [PATCH 1/6] Support Laravel 11 Test --- .github/workflows/run-tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ec52cbc..8da058a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -14,16 +14,22 @@ jobs: matrix: os: [ubuntu-latest] php: [8.0, 8.1, 8.2, 8.3] - laravel: [10.*, 9.*] - stability: [prefer-lowest, prefer-stable] + laravel: [11.*, 10.*, 9.*] + stability: [prefer-stable] include: - laravel: 9.* testbench: 7.* - laravel: 10.* testbench: 8.* + - laravel: 11.* + testbench: 9.* exclude: - laravel: 10.* php: 8.0 + - laravel: 11.* + php: 8.0 + - laravel: 11.* + php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} From 0f21144a2805bb0490824b44c9ebf5ae78e4fbe8 Mon Sep 17 00:00:00 2001 From: askdkc Date: Wed, 17 Jan 2024 10:27:00 +0900 Subject: [PATCH 2/6] Test for Laravel 11 --- tests/CommandTest.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 1c0c284..09d7bfd 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -1,5 +1,9 @@ assertFileExists(base_path('.env')); +}); + test('breezejp command successfully run and see all the published files', closure: function () { $this->artisan('breezejp') ->expectsOutput('Laravel Breeze用に日本語翻訳ファイルを準備します') @@ -21,10 +25,17 @@ ->expectsOutput('日本語ファイルのインストールが完了しました!') ->assertExitCode(0); - $configfile = file_get_contents(base_path('config/app.php')); - $this->assertStringContainsString("'locale' => 'ja'", $configfile); - $this->assertStringContainsString("'faker_locale' => 'ja_JP'", $configfile); - $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + if ((int) substr(Illuminate\Foundation\Application::VERSION, 0, 2) < 11) { + $configfile = file_get_contents(base_path('config/app.php')); + $this->assertStringContainsString("'locale' => 'ja'", $configfile); + $this->assertStringContainsString("'faker_locale' => 'ja_JP'", $configfile); + $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + } else { // For Laravel 11 and above + $configfile = file_get_contents(base_path('.env')); + $this->assertStringContainsString('APP_LOCALE=ja', $configfile); + $this->assertStringContainsString('APP_FAKER_LOCALE=ja_JP', $configfile); + $this->assertStringContainsString('APP_TIMEZONE=Asia/Tokyo', $configfile); + } }); test('breezejp command successfully update config/app.php timezone to Asia/Tokyo', function () { @@ -34,6 +45,11 @@ ->expectsOutput('日本語ファイルのインストールが完了しました!') ->assertExitCode(0); - $configfile = file_get_contents(base_path('config/app.php')); - $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + if ((int) substr(Illuminate\Foundation\Application::VERSION, 0, 2) < 11) { + $configfile = file_get_contents(base_path('config/app.php')); + $this->assertStringContainsString("'timezone' => 'Asia/Tokyo'", $configfile); + } else { // For Laravel 11 and above + $configfile = file_get_contents(base_path('.env')); + $this->assertStringContainsString('APP_TIMEZONE=Asia/Tokyo', $configfile); + } }); From 0bd3145e108928447c72c1841ab8160cda0cdc61 Mon Sep 17 00:00:00 2001 From: askdkc Date: Wed, 17 Jan 2024 10:28:59 +0900 Subject: [PATCH 3/6] Need to prepare .env for Laravel 11 test --- tests/TestCase.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/TestCase.php b/tests/TestCase.php index 0ff1962..185b27a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -12,6 +12,8 @@ protected function setUp(): void { parent::setUp(); + copy(__DIR__.'/../vendor/orchestra/testbench-core/laravel/.env.example', __DIR__.'/../vendor/orchestra/testbench-core/laravel/.env'); + // テスト用のファイルが残ってたら消す(web.php) if (is_file(__DIR__.'/../vendor/orchestra/testbench-core/laravel/routes/web.php')) { unlink(__DIR__.'/../vendor/orchestra/testbench-core/laravel/routes/web.php'); @@ -56,6 +58,17 @@ protected function setUp(): void file_put_contents(__DIR__.'/../vendor/orchestra/testbench-core/laravel/config/app.php', $configfile); } + protected function tearDown(): void + { + parent::tearDown(); + + // テスト用のファイルが残ってたら消す(.env) + if (is_file(__DIR__.'/../vendor/orchestra/testbench-core/laravel/.env')) { + unlink(__DIR__.'/../vendor/orchestra/testbench-core/laravel/.env'); + } + + } + protected function getPackageProviders($app) { return [ From a6d3f9605c5700045c6932c55452bdccfeefb047 Mon Sep 17 00:00:00 2001 From: askdkc Date: Wed, 17 Jan 2024 10:29:26 +0900 Subject: [PATCH 4/6] Update to Support Laravel 11 --- src/Commands/BreezejpCommand.php | 51 ++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/src/Commands/BreezejpCommand.php b/src/Commands/BreezejpCommand.php index 94d4be7..7303166 100644 --- a/src/Commands/BreezejpCommand.php +++ b/src/Commands/BreezejpCommand.php @@ -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'; @@ -56,5 +94,6 @@ public function handle(): int $this->info('日本語ファイルのインストールが完了しました!'); return self::SUCCESS; + } } From 206a198f23dbc9980cd94d0a69da035737a0be5d Mon Sep 17 00:00:00 2001 From: askdkc Date: Wed, 17 Jan 2024 10:33:43 +0900 Subject: [PATCH 5/6] Update composer.json to include Laravel 11 --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ac49a8a..367e49e 100644 --- a/composer.json +++ b/composer.json @@ -21,16 +21,16 @@ "require": { "php": "^8.0", "spatie/laravel-package-tools": "^1.14.0", - "illuminate/contracts": "^9.28|^10.0" + "illuminate/contracts": "^9.28|^10.0|^11.0" }, "require-dev": { "laravel/pint": "^1.4", - "nunomaduro/collision": "^6.0|^7.0", - "nunomaduro/larastan": "^2.0", - "orchestra/testbench": "^7.7|^8.0", - "pestphp/pest": "^1.22|^2.0", + "nunomaduro/collision": "^6.0|^7.0|^8.0", + "larastan/larastan": "^2.0", + "orchestra/testbench": "^7.7|^8.0|^9.0", + "pestphp/pest": "^1.22|^2.0|^3.0", "phpstan/extension-installer": "^1.2", - "phpunit/phpunit": "^9.5.27|^10.0" + "phpunit/phpunit": "^9.5.27|^10.0|^11.0" }, "autoload": { "psr-4": { From 7439068e48e8fcab6150bf899d2ccb2f4d73b653 Mon Sep 17 00:00:00 2001 From: askdkc Date: Fri, 26 Jan 2024 09:41:16 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Laravel=2011=E5=AF=BE=E5=BF=9C=E3=82=92?= =?UTF-8?q?=E8=A8=98=E8=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5b90338..aebec79 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [![Total Downloads](https://img.shields.io/packagist/dt/askdkc/breezejp.svg)](https://packagist.org/packages/askdkc/breezejp) [![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/askdkc) +## Laravel 11にも対応済みです(2024-01-26) + ## これは何? TL;DR Laravelを下記2コマンドだけで自動で日本語化できちゃうパッケージです👍 ```bash