DiUS / java-faker

Brings the popular ruby faker gem to Java
http://dius.github.io/java-faker
Other
4.72k stars 845 forks source link

Cant generate address by Locale #494

Open amedvedjev opened 4 years ago

amedvedjev commented 4 years ago

Describe the bug I am trying to generate fake address data by country using supported locales.

To Reproduce

        Faker faker = new Faker(new Locale("en-US"));
        System.out.println(String.format("en-US: %s", faker.address().country()));
        faker = new Faker(new Locale("hu"));
        System.out.println(String.format("hu: %s", faker.address().country()));
        faker = new Faker(Locale.FRANCE);
        System.out.println(String.format("FRANCE: %s", faker.address().country()));
        faker = new Faker(Locale.UK);
        System.out.println(String.format("UK: %s", faker.address().country()));

Expected behavior Real address data per selected locale.

Result Random data.

en-US: Panama
hu: Málta
FRANCE: Kyrgyz Republic
UK: Fiji

Versions:

Juan-Chen45 commented 3 years ago

Our group are interested in this issue, we will try to fix it. ---- SE_Sustech

Jiapeng-Pei commented 3 years ago

Unfortunately, the way you use javafaker is wrong. France/UK are countries that don't contain other countries, even if you set these locale, faker.address.country() still return random countries. You can call faker.address.city() or faker.address.state() and the result will be right.

cheekymonkat commented 3 years ago

I am also having the same problem

Faker.instance(new Locale("en","GB")).address().state()

returns US states not UK. The whole address is affected - It doesn't happen with other locales.

youyumeimei commented 2 years ago

Hello @amedvedjev , our group are interested in this issue, and we will try to fix it. ---- SE_SUSTech, group: Lanrand

bodiam commented 2 years ago

@youyumeimei this library is no longer maintained. An active fork is hosted at www.datafaker.net

Would you be willing to contribute there? We release a new version every month.