Closed Strongground closed 2 years ago
Hello,
You can retrieve the global locale setting through faker.locale
. By default, this will return "en_US".
Unfortunately, the returned values are not in those ISO formats because of the faker.js library, but you can see below all the values that are available in Fake Data:
{
'ar': 'Arabic',
'az': 'Azerbaijani',
'zh_CN': 'Chinese',
'zh_TW': 'Chinese (Taiwan)',
'cz': 'Czech',
'nl': 'Dutch',
'nl_BE': 'Dutch (Belgium)',
'de': 'German',
'de_AT': 'German (Austria)',
'de_CH': 'German (Switzerland)',
'en': 'English',
"en_AU": "English (Australia)",
'en_AU_ocker': 'English (Australia Ocker)',
'en_BORK': 'English (Bork)',
'en_CA': 'English (Canada)',
'en_GB': 'English (Great Britain)',
'en_IND': 'English (India)',
'en_IE': 'English (Ireland)',
'en_ZA': 'English (South Africa)',
'en_US': 'English (United States)',
'fa': 'Farsi',
'fi': 'Finnish',
'fr': 'French',
'fr_CA': 'French (Canada)',
'fr_CH': 'French (Switzerland)',
'ge': 'Georgian',
'id_ID': 'Indonesia',
'it': 'Italian',
'ja': 'Japanese',
'ko': 'Korean',
'nep': 'Nepalese',
'nb_NO': 'Norwegian',
'pl': 'Polish',
'pt_BR': 'Portuguese (Brazil)',
'pt_PT': 'Portuguese (Portugal)',
'ro': 'Romanian',
'ru': 'Russian',
'sk': 'Slovakian',
'es': 'Spanish',
'es_MX': 'Spanish (Mexico)',
'sv': 'Swedish',
'tr': 'Turkish',
'uk': 'Ukrainian',
'vi': 'Vietnamese',
}
You are amazing! Thanks a bunch!
Hi! I want to start saying that I
hatelove your app! However, when writing a custom generator that returns for example a random birthday, and the form expects this data to be in a certain format, at the moment I need to build several custom generators for this (e.g. "Birthday (US)", "Birthday (Germany)" and so on). I would love to be able to access the currently selected locale (from Settings) so I can switch the locale in my custom generator, e.g.randomBday(start, end).toLocaleDateString(fakeData.currentLocale)
Perfect pattern for locale would be ISO 639‑1-ISO 3166‑1, e.g. "en-US" or "de-DE".