java-faker
java-faker copied to clipboard
Cant generate address by Locale
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:
- OS: macOS 10.15.3
- JDK: 1.8.0_231-b11
- Faker Version: 1.0.2
Our group are interested in this issue, we will try to fix it. ---- SE_Sustech
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.
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.
Hello @amedvedjev , our group are interested in this issue, and we will try to fix it. ---- SE_SUSTech, group: Lanrand
@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.