11

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

YanDatsiuk
  • 1,885
  • 2
  • 18
  • 30

1 Answers1

12

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();
Ulrik
  • 493
  • 2
  • 16