bchavez / Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Other
8.62k stars 491 forks source link

The locale 'en-CA' does not exist. #444

Closed loukaspd closed 1 year ago

loukaspd commented 1 year ago

Version Information

Software Version(s)
Bogus NuGet Package 34.0.2
.NET Core? 6.0

I'm trying to use bogus with locale en-CA but I get the following error:

Bogus.BogusException: The locale 'en-CA' does not exist. To see all available locales visit https://github.com/bchavez/Bogus.
   at Bogus.DataSet..ctor(String locale)
   at Bogus.DataSets.Address..ctor(String locale)
   at Bogus.Faker..ctor(String locale)

The error appears when I'm trying to instantiate the Faker class with this locale:

var faker = new Faker("en-CA");
bchavez commented 1 year ago

Use an underscore, not a hyphen as shown below:

void Main()
{
   try {
      var f1 = new Faker("en_CA");
      f1.Address.State().Dump();
   }
   catch {
      "Underscore 'en_CA' doesn't work".Dump(); 
   }

   try
   {
      var f2 = new Faker("en-CA");
      f2.Address.State().Dump();
   }
   catch {
      "Hyphen 'en-CA' doesn't work".Dump();
   }
}

image