Framework: Faker locale configuration does not work.

Created on 19 Oct 2019  路  7Comments  路  Source: laravel/framework

  • Laravel Version: 5.8.35
  • PHP Version: 7.2.19
  • Database Driver & Version: psql (PostgreSQL) 11.5

The locale configuration for faker in config > app.php does not work.

Steps To Reproduce:

  • Set the locale to config > app.php
    image

  • Create a model factory (country)
    image

  • Running the seed
    image

The results are in English:
image

But if I modify the model factory this way:
image

The results are displayed in the desired language
image

Most helpful comment

Laravel 5.8 is not supported anymore and it works under Laravel 6. You can run config('app.faker_locale') to verify your setting got recognized but you should update.

Also personally I think all code and database identifier should be in English.

All 7 comments

Laravel 5.8 is not supported anymore and it works under Laravel 6. You can run config('app.faker_locale') to verify your setting got recognized but you should update.

Also personally I think all code and database identifier should be in English.

It's not available in 5.8. It got reverted. https://github.com/laravel/framework/pull/29250

But that's for the tests, the seeders should get the faker instance from here.

Hey there,

Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? We'll help you out and re-open this issue if so.

Thanks!

I'm experiencing the same issue on the latest release (6.15.0).
The faker locale doesn't seem to be applied anywhere, no matter what I try.
I tried using my factory on an endpoint, in a test, and in a seeder. The resulting data is always from the en_US provider. Dumping my faker_locale in my factory class confirms it's not a caching issue and the faker_locale is in fact set to something else (nl_BE in my case).

@Vercoutere this is happening due to the change in https://github.com/laravel/framework/pull/30992 - I can no longer get locale fake data either using the WithFaker trait.

I was having trouble with faker not respecting the locale value of app.php, turns out there was some stuff cached with the old value.

I ran php artisan config:cache and it solved the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

digirew picture digirew  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

shopblocks picture shopblocks  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

YannPl picture YannPl  路  3Comments