1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravelでダミーデータ(Factory&Faker) が日本語化できない時の対処法

Posted at

初学者です。エラー解決を軽めに発信していきます。

開発環境

PHP 7.3.9
MAMP 5.7
Mysql 5.7.26
Laravel 6.20.7

問題

Laravelで日本語のダミーデータを作成しようとして、config/app.php内で、

config/app.php
'faker_locale' => 'ja_JP',

と記入したんですが、なぜか'ja_JP'としているのに英語でダミーデータが作成されてしまいました。
今までは全て日本語化できていたのに...

対処法

まあ単純に考えて、英語ではあるけどダミーデータは作成されているから、FactoryやFaker、Seederのファイルには問題はないはずなので、config自体の変更が反映されていない可能性がありますね。

調べてみると、
「開発環境でconfigファイルを編集したらキャッシュをクリアしないとキャッシュが反映されてしまう」
らしいです。

$ php artisan config:clear

ターミナルでキャッシュをクリアしてからダミーデータを作成したら日本語化できていました!
よかった!!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?