{"record":{"id":"6870883cc90c37a2","repo":"bchavez/Bogus","slug":"the-locale-locale-does-not-exist-to-see-all-a","errorCode":null,"errorMessage":"The locale '{locale}' does not exist. To see all available locales visit {AssemblyVersionInformation.AssemblyDescription}.","messagePattern":"The locale '(.+?)' does not exist\\. To see all available locales visit (.+?)\\.","errorType":"exception","errorClass":"BogusException","httpStatus":null,"severity":"error","filePath":"Source/Bogus/DataSet.cs","lineNumber":24,"sourceCode":"namespace Bogus;\n\n/// <summary>\n/// Data set methods that access the BSON database of locales.\n/// </summary>\npublic class DataSet : ILocaleAware, IHasRandomizer\n{\n   /// <summary>\n   /// Initializes a new instance of the <see cref=\"DataSet\"/> class.\n   /// </summary>\n   /// <param name=\"locale\">The locale wanting to be set. Default is \"en\" for English.</param>\n   /// <exception cref=\"BogusException\">\n   /// When the given <paramref name=\"locale\"/> isn't found.\n   /// </exception>\n   public DataSet(string locale = \"en\")\n   {\n      if (!Database.LocaleResourceExists(locale))\n      {\n         throw new BogusException(\n            $\"The locale '{locale}' does not exist. To see all available locales visit {AssemblyVersionInformation.AssemblyDescription}.\");\n      }\n\n      this.Locale = locale;\n\n      this.Category = ResolveCategory(this.GetType());\n   }\n\n   /// <summary>\n   /// Gets or sets the category name inside the locale.\n   /// </summary>\n   protected string Category { get; set; }\n\n   /// <summary>\n   /// Gets or sets the current locale of the data set.\n   /// </summary>\n   public string Locale { get; set; }\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/bchavez/Bogus/blob/6ece18c5c22648ab4606e45a0aaf2f07fc5259e4/Source/Bogus/DataSet.cs#L6-L42","documentation":"Thrown by the DataSet constructor when Database.LocaleResourceExists(locale) returns false, i.e. the supplied locale string does not match any locale JSON resource embedded in the Bogus assembly. The message appends AssemblyVersionInformation.AssemblyDescription to point at the project/GitHub URL where the locale list lives. Bogus uses underscore-delimited locale codes (e.g. \"en_US\"), not .NET hyphenated culture names (\"en-US\").","triggerScenarios":"Calling new DataSet(\"de-DE\"), new Faker<T>(\"en-US\"), new Person(\"xy_ZZ\") or any API that takes a locale string with a code that is not one of the bundled locales. Also triggered by typos, wrong casing, or passing a full culture name where a Bogus locale code is expected.","commonSituations":"Copying a .NET CultureInfo.Name (hyphen form like \"en-US\", \"pt-BR\") straight into a Faker constructor. Using a locale Bogus does not bundle. Upgrading Bogus and assuming a locale that was never shipped exists.","solutions":["Replace the hyphenated culture name with the Bogus underscore locale code, e.g. \"en_US\" instead of \"en-US\".","Call Bogus.Database.GetAllLocales() to print the exact set of supported locale codes and copy one verbatim.","Fall back to the default \"en\" locale while you confirm the exact code you need."],"exampleFix":"// before\nvar f = new Faker<MyObj>(\"en-US\");\n\n// after\nvar f = new Faker<MyObj>(\"en_US\");","handlingStrategy":"validation","validationCode":"using Bogus;\n\nstring locale = \"en_US\";\nif (!Database.LocaleResourceExists(locale))\n{\n    var valid = string.Join(\", \", Database.GetAllLocales());\n    throw new ArgumentException($\"Locale '{locale}' is not bundled. Valid: {valid}\");\n}\nvar faker = new Faker<MyObj>(locale);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the underscore locale form (en_US), never the hyphen culture form (en-US).","Call Database.GetAllLocales() once at startup and log the set your Bogus version supports.","Treat locale as a known constant, not free user input."],"tags":["locale","configuration","i18n","argument-validation"],"backgroundTag":null,"analyzedSha":"6ece18c5c22648ab4606e45a0aaf2f07fc5259e4","analyzedAt":"2026-08-13T21:08:15.463Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}