In Laravel I use Faker. (fzaninotto/Faker)
Can't change locale(language) of generated texts.
My code:
use Faker\Factory as Faker;
class MySeeder extends Seeder {
public function run() {
$faker = Faker::create('ru_RU');
$randomSentence = $faker->sentence();
...
}
}
But, as result $randomSentence
contains generated text from default locale ('en_EN').
P.S. Faker is updated. Folder '\vendor\fzaninotto\faker\src\Faker\Provider\ru_RU' contains Text.php
The reason you're not getting Russian text from the sentence()
method is that it's not using the text from Text.php
.
The sentence()
method is defined in Lorem.php and uses the wordlist in that file. You either need to use the realText()
method, or implement a Russian version of the wordlist (which the Faker author has already said no to)
In short, you need to use this line to get russian text:
$faker = Faker::create('ru_RU');
$randomSentence = $faker->realText();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With