faker
faker copied to clipboard
Provide language tag / BCP 47 for each locale
Clear and concise description of the problem
Currently we have the name of a locale only available at compile time or need to access them e.g. via Object.keys(faker.locales)
But some feature requests like #350 need the BCP 47 language tag
But not only for this, but also for other features in the future it could be useful to access the language tag at runtime inside faker, or e.g. fetch it from the current used locale when we do not have locale as in v7 anymore
Suggested solution
Add a new key like title and separator into the locale definitions (at root level for a LocaleDefinition)
Alternative
Not sure if we might want to add several tags/keys because there is a locale and a country part. Also not sure if there are other important formats we need to benefit from. (At least BCP 47 is the one that is mentioned in the JS mozilla docs)
Additional context
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#parameters
- #350
- https://www.techonthenet.com/js/language_tags.php