Generate Fake Localized Data with Laravel

Instead of populating the database by yourself, Laravel integrates the Faker package which is used to generate English data into your database. Though, what if you want to generate data in your own language?

When testing, it is common to need to insert a few records into your database before executing your test. In version 5.1 Laravel introduced model factories to easily generate fake data into your applications.

If you want to specify a custom locale, you can create a new service provider and overwrite the default locale. In my case, I want the data in Swedish. You can find a full list of locales here.

Once the service provider is created. Add the service provider to the providers array in config/app.php.


That’s it, you are now ready to generate fake data in any language you want!