diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 38715b97a4a..6fcbe177ece 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -17,6 +17,7 @@ import { resolve } from 'node:path'; import type { Options } from 'prettier'; import { format } from 'prettier'; import options from '../.prettierrc.cjs'; +import { faker } from '../src'; import type { LocaleDefinition } from '../src/definitions'; import { DEFINITIONS } from '../src/definitions'; @@ -81,19 +82,22 @@ function containsAll(checked?: string[], expected?: string[]): boolean { } function generateLocaleFile(locale: string): void { + faker.setLocale(locale); + + const localeOrder = faker.localeOrder; + let content = ` ${autoGeneratedCommentHeader} import { Faker } from '../faker'; - import ${locale} from '../locales/${locale}'; - ${locale !== 'en' ? "import en from '../locales/en';" : ''} + ${localeOrder + .map((entry) => `import ${entry} from '../locales/${entry}';`) + .join('\n')} const faker = new Faker({ - locale: '${locale}', - localeFallback: 'en', + localeOrder: ${JSON.stringify(localeOrder)}, locales: { - ${locale}, - ${locale !== 'en' ? 'en,' : ''} + ${localeOrder.map((entry) => `${entry},`).join('\n')} }, }); diff --git a/src/faker.ts b/src/faker.ts index 278e0219485..40f89205689 100644 --- a/src/faker.ts +++ b/src/faker.ts @@ -38,14 +38,12 @@ export type UsedLocales = Partial>; export interface FakerOptions { locales: UsedLocales; - locale?: UsableLocale; - localeFallback?: UsableLocale; + localeOrder?: UsableLocale[]; } export class Faker { locales: UsedLocales; - locale: UsableLocale; - localeFallback: UsableLocale; + localeOrder: UsableLocale[]; readonly definitions: LocaleDefinition = this.initDefinitions(); @@ -95,25 +93,35 @@ export class Faker { } this.locales = opts.locales; - this.locale = opts.locale || 'en'; - this.localeFallback = opts.localeFallback || 'en'; + this.localeOrder = opts.localeOrder ?? ['en']; } /** * Creates a Proxy based LocaleDefinition that virtually merges the locales. */ private initDefinitions(): LocaleDefinition { + // Returns the first resolved locale data that aren't undefined + const findFirst = ( + resolver: (data: LocaleDefinition) => T | undefined + ): T | undefined => { + for (const locale of this.localeOrder) { + const baseData = resolver(this.locales[locale]); + if (baseData != null) { + return baseData; + } + } + return undefined; + }; + // Returns the first LocaleDefinition[key] in any locale const resolveBaseData = (key: keyof LocaleDefinition): unknown => - this.locales[this.locale][key] ?? this.locales[this.localeFallback][key]; + findFirst((data) => data[key]); // Returns the first LocaleDefinition[module][entry] in any locale const resolveModuleData = ( module: keyof LocaleDefinition, entry: string - ): unknown => - this.locales[this.locale][module]?.[entry] ?? - this.locales[this.localeFallback][module]?.[entry]; + ): unknown => findFirst((data) => data[module]?.[entry]); // Returns a proxy that can return the entries for a module (if it exists) const moduleLoader = ( @@ -159,11 +167,25 @@ export class Faker { } /** - * Set Faker's locale + * Set Faker's locale using the default fallback strategy. * * @param locale The locale to set (e.g. `en` or `en_AU`, `en_AU_ocker`). + * @param fallbacks The fixed fallbacks to use. Defaults to `['en']`. */ - setLocale(locale: UsableLocale): void { - this.locale = locale; + setLocale(locale: UsableLocale, fallbacks: UsableLocale[] = ['en']): void { + const localeOrder = []; + const parts = locale.split('_'); + for (let i = parts.length; i > 0; i--) { + const subLocale = parts.slice(0, i).join('_'); + if (this.locales[subLocale] != null) { + localeOrder.push(subLocale); + } + } + for (const fallback of fallbacks) { + if (!localeOrder.includes(fallback) && this.locales[fallback] != null) { + localeOrder.push(fallback); + } + } + this.localeOrder = localeOrder; } } diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index c47297fdf28..8300a849008 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -8,8 +8,7 @@ import af_ZA from '../locales/af_ZA'; import en from '../locales/en'; const faker = new Faker({ - locale: 'af_ZA', - localeFallback: 'en', + localeOrder: ['af_ZA', 'en'], locales: { af_ZA, en, diff --git a/src/locale/ar.ts b/src/locale/ar.ts index e396c1739b8..6e478091702 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -8,8 +8,7 @@ import ar from '../locales/ar'; import en from '../locales/en'; const faker = new Faker({ - locale: 'ar', - localeFallback: 'en', + localeOrder: ['ar', 'en'], locales: { ar, en, diff --git a/src/locale/az.ts b/src/locale/az.ts index 3249a33c2a1..52dc053862e 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -8,8 +8,7 @@ import az from '../locales/az'; import en from '../locales/en'; const faker = new Faker({ - locale: 'az', - localeFallback: 'en', + localeOrder: ['az', 'en'], locales: { az, en, diff --git a/src/locale/cz.ts b/src/locale/cz.ts index 1a2460118e9..22945c20b03 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -8,8 +8,7 @@ import cz from '../locales/cz'; import en from '../locales/en'; const faker = new Faker({ - locale: 'cz', - localeFallback: 'en', + localeOrder: ['cz', 'en'], locales: { cz, en, diff --git a/src/locale/de.ts b/src/locale/de.ts index 3968cb4af0f..87d2638adfd 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -8,8 +8,7 @@ import de from '../locales/de'; import en from '../locales/en'; const faker = new Faker({ - locale: 'de', - localeFallback: 'en', + localeOrder: ['de', 'en'], locales: { de, en, diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index 9eefa8251dc..7d76b46aaff 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -4,14 +4,15 @@ */ import { Faker } from '../faker'; +import de from '../locales/de'; import de_AT from '../locales/de_AT'; import en from '../locales/en'; const faker = new Faker({ - locale: 'de_AT', - localeFallback: 'en', + localeOrder: ['de_AT', 'de', 'en'], locales: { de_AT, + de, en, }, }); diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index e3eadf9d920..45870244a6d 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -4,14 +4,15 @@ */ import { Faker } from '../faker'; +import de from '../locales/de'; import de_CH from '../locales/de_CH'; import en from '../locales/en'; const faker = new Faker({ - locale: 'de_CH', - localeFallback: 'en', + localeOrder: ['de_CH', 'de', 'en'], locales: { de_CH, + de, en, }, }); diff --git a/src/locale/el.ts b/src/locale/el.ts index 39c0ec53bc8..083ffc8328b 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -8,8 +8,7 @@ import el from '../locales/el'; import en from '../locales/en'; const faker = new Faker({ - locale: 'el', - localeFallback: 'en', + localeOrder: ['el', 'en'], locales: { el, en, diff --git a/src/locale/en.ts b/src/locale/en.ts index d003817e537..a5a9e75d8e2 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -7,8 +7,7 @@ import { Faker } from '../faker'; import en from '../locales/en'; const faker = new Faker({ - locale: 'en', - localeFallback: 'en', + localeOrder: ['en'], locales: { en, }, diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index 2e6afe5a259..b0973387dbd 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_AU from '../locales/en_AU'; const faker = new Faker({ - locale: 'en_AU', - localeFallback: 'en', + localeOrder: ['en_AU', 'en'], locales: { en_AU, en, diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index 4330f6ed550..aa70c4b8f48 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -5,13 +5,14 @@ import { Faker } from '../faker'; import en from '../locales/en'; +import en_AU from '../locales/en_AU'; import en_AU_ocker from '../locales/en_AU_ocker'; const faker = new Faker({ - locale: 'en_AU_ocker', - localeFallback: 'en', + localeOrder: ['en_AU_ocker', 'en_AU', 'en'], locales: { en_AU_ocker, + en_AU, en, }, }); diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index 3089a61d583..281c112ceaf 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_BORK from '../locales/en_BORK'; const faker = new Faker({ - locale: 'en_BORK', - localeFallback: 'en', + localeOrder: ['en_BORK', 'en'], locales: { en_BORK, en, diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index 6fbb6db25df..aae6e64811b 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_CA from '../locales/en_CA'; const faker = new Faker({ - locale: 'en_CA', - localeFallback: 'en', + localeOrder: ['en_CA', 'en'], locales: { en_CA, en, diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index baed972d054..b62ef334cec 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_GB from '../locales/en_GB'; const faker = new Faker({ - locale: 'en_GB', - localeFallback: 'en', + localeOrder: ['en_GB', 'en'], locales: { en_GB, en, diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index da396c5aea1..cc99a62e870 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_GH from '../locales/en_GH'; const faker = new Faker({ - locale: 'en_GH', - localeFallback: 'en', + localeOrder: ['en_GH', 'en'], locales: { en_GH, en, diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index 2b0f92b8a99..54e6bc05719 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_IE from '../locales/en_IE'; const faker = new Faker({ - locale: 'en_IE', - localeFallback: 'en', + localeOrder: ['en_IE', 'en'], locales: { en_IE, en, diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index 16a753be517..619f102f825 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_IND from '../locales/en_IND'; const faker = new Faker({ - locale: 'en_IND', - localeFallback: 'en', + localeOrder: ['en_IND', 'en'], locales: { en_IND, en, diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index f9d49152865..3c5e0435f9b 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_NG from '../locales/en_NG'; const faker = new Faker({ - locale: 'en_NG', - localeFallback: 'en', + localeOrder: ['en_NG', 'en'], locales: { en_NG, en, diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index ec6a6cc0bec..0c1ea128f63 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_US from '../locales/en_US'; const faker = new Faker({ - locale: 'en_US', - localeFallback: 'en', + localeOrder: ['en_US', 'en'], locales: { en_US, en, diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index 2eb13622429..cc5934e707c 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import en_ZA from '../locales/en_ZA'; const faker = new Faker({ - locale: 'en_ZA', - localeFallback: 'en', + localeOrder: ['en_ZA', 'en'], locales: { en_ZA, en, diff --git a/src/locale/es.ts b/src/locale/es.ts index b5485698ca6..de8b7bc7af2 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import es from '../locales/es'; const faker = new Faker({ - locale: 'es', - localeFallback: 'en', + localeOrder: ['es', 'en'], locales: { es, en, diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index ff954d8c415..76055d7c566 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -5,13 +5,14 @@ import { Faker } from '../faker'; import en from '../locales/en'; +import es from '../locales/es'; import es_MX from '../locales/es_MX'; const faker = new Faker({ - locale: 'es_MX', - localeFallback: 'en', + localeOrder: ['es_MX', 'es', 'en'], locales: { es_MX, + es, en, }, }); diff --git a/src/locale/fa.ts b/src/locale/fa.ts index 62e63d8ded6..ef7b49e6159 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import fa from '../locales/fa'; const faker = new Faker({ - locale: 'fa', - localeFallback: 'en', + localeOrder: ['fa', 'en'], locales: { fa, en, diff --git a/src/locale/fi.ts b/src/locale/fi.ts index ecdecb88b15..acf45f594db 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import fi from '../locales/fi'; const faker = new Faker({ - locale: 'fi', - localeFallback: 'en', + localeOrder: ['fi', 'en'], locales: { fi, en, diff --git a/src/locale/fr.ts b/src/locale/fr.ts index e767c582397..7d764c2e4f4 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import fr from '../locales/fr'; const faker = new Faker({ - locale: 'fr', - localeFallback: 'en', + localeOrder: ['fr', 'en'], locales: { fr, en, diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index f98b7c8c5aa..7fdda21b978 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -5,13 +5,14 @@ import { Faker } from '../faker'; import en from '../locales/en'; +import fr from '../locales/fr'; import fr_BE from '../locales/fr_BE'; const faker = new Faker({ - locale: 'fr_BE', - localeFallback: 'en', + localeOrder: ['fr_BE', 'fr', 'en'], locales: { fr_BE, + fr, en, }, }); diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index 30e73bdbdbd..bad907c2d83 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -5,13 +5,14 @@ import { Faker } from '../faker'; import en from '../locales/en'; +import fr from '../locales/fr'; import fr_CA from '../locales/fr_CA'; const faker = new Faker({ - locale: 'fr_CA', - localeFallback: 'en', + localeOrder: ['fr_CA', 'fr', 'en'], locales: { fr_CA, + fr, en, }, }); diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index f04588b54cd..7ac36988199 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -5,13 +5,14 @@ import { Faker } from '../faker'; import en from '../locales/en'; +import fr from '../locales/fr'; import fr_CH from '../locales/fr_CH'; const faker = new Faker({ - locale: 'fr_CH', - localeFallback: 'en', + localeOrder: ['fr_CH', 'fr', 'en'], locales: { fr_CH, + fr, en, }, }); diff --git a/src/locale/ge.ts b/src/locale/ge.ts index 7734e2d33a1..5241d1d32e8 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ge from '../locales/ge'; const faker = new Faker({ - locale: 'ge', - localeFallback: 'en', + localeOrder: ['ge', 'en'], locales: { ge, en, diff --git a/src/locale/he.ts b/src/locale/he.ts index a029ea62114..73b06b6f3f5 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import he from '../locales/he'; const faker = new Faker({ - locale: 'he', - localeFallback: 'en', + localeOrder: ['he', 'en'], locales: { he, en, diff --git a/src/locale/hr.ts b/src/locale/hr.ts index 1a8447155fb..04bd6dfd481 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import hr from '../locales/hr'; const faker = new Faker({ - locale: 'hr', - localeFallback: 'en', + localeOrder: ['hr', 'en'], locales: { hr, en, diff --git a/src/locale/hy.ts b/src/locale/hy.ts index ae584be3529..b101d34f59f 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import hy from '../locales/hy'; const faker = new Faker({ - locale: 'hy', - localeFallback: 'en', + localeOrder: ['hy', 'en'], locales: { hy, en, diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index 026086611df..c2941cd667a 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import id_ID from '../locales/id_ID'; const faker = new Faker({ - locale: 'id_ID', - localeFallback: 'en', + localeOrder: ['id_ID', 'en'], locales: { id_ID, en, diff --git a/src/locale/it.ts b/src/locale/it.ts index 40daaa65432..3338719fae2 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import it from '../locales/it'; const faker = new Faker({ - locale: 'it', - localeFallback: 'en', + localeOrder: ['it', 'en'], locales: { it, en, diff --git a/src/locale/ja.ts b/src/locale/ja.ts index 4866ad92ead..3197b63a06e 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ja from '../locales/ja'; const faker = new Faker({ - locale: 'ja', - localeFallback: 'en', + localeOrder: ['ja', 'en'], locales: { ja, en, diff --git a/src/locale/ko.ts b/src/locale/ko.ts index b6d975893b2..85c1f1ac481 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ko from '../locales/ko'; const faker = new Faker({ - locale: 'ko', - localeFallback: 'en', + localeOrder: ['ko', 'en'], locales: { ko, en, diff --git a/src/locale/lv.ts b/src/locale/lv.ts index 89349b51e96..4aea5cb80dc 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import lv from '../locales/lv'; const faker = new Faker({ - locale: 'lv', - localeFallback: 'en', + localeOrder: ['lv', 'en'], locales: { lv, en, diff --git a/src/locale/mk.ts b/src/locale/mk.ts index c5b9a584002..849dbab0910 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import mk from '../locales/mk'; const faker = new Faker({ - locale: 'mk', - localeFallback: 'en', + localeOrder: ['mk', 'en'], locales: { mk, en, diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index 9c768999e40..90f53742111 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import nb_NO from '../locales/nb_NO'; const faker = new Faker({ - locale: 'nb_NO', - localeFallback: 'en', + localeOrder: ['nb_NO', 'en'], locales: { nb_NO, en, diff --git a/src/locale/ne.ts b/src/locale/ne.ts index 1527d4136ac..95c484b592e 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ne from '../locales/ne'; const faker = new Faker({ - locale: 'ne', - localeFallback: 'en', + localeOrder: ['ne', 'en'], locales: { ne, en, diff --git a/src/locale/nl.ts b/src/locale/nl.ts index c4adac22204..1b51f87fd49 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import nl from '../locales/nl'; const faker = new Faker({ - locale: 'nl', - localeFallback: 'en', + localeOrder: ['nl', 'en'], locales: { nl, en, diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index 57c23f2e08d..ddfca9b2189 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -5,13 +5,14 @@ import { Faker } from '../faker'; import en from '../locales/en'; +import nl from '../locales/nl'; import nl_BE from '../locales/nl_BE'; const faker = new Faker({ - locale: 'nl_BE', - localeFallback: 'en', + localeOrder: ['nl_BE', 'nl', 'en'], locales: { nl_BE, + nl, en, }, }); diff --git a/src/locale/pl.ts b/src/locale/pl.ts index 32489ea9484..784084c41b1 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import pl from '../locales/pl'; const faker = new Faker({ - locale: 'pl', - localeFallback: 'en', + localeOrder: ['pl', 'en'], locales: { pl, en, diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index fd91879ec23..c9dd4e062d8 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import pt_BR from '../locales/pt_BR'; const faker = new Faker({ - locale: 'pt_BR', - localeFallback: 'en', + localeOrder: ['pt_BR', 'en'], locales: { pt_BR, en, diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 8233d8cd746..719fb2378e4 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import pt_PT from '../locales/pt_PT'; const faker = new Faker({ - locale: 'pt_PT', - localeFallback: 'en', + localeOrder: ['pt_PT', 'en'], locales: { pt_PT, en, diff --git a/src/locale/ro.ts b/src/locale/ro.ts index 45d97cbf990..ac84e264a67 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ro from '../locales/ro'; const faker = new Faker({ - locale: 'ro', - localeFallback: 'en', + localeOrder: ['ro', 'en'], locales: { ro, en, diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 753d218f7fa..e929c156be0 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ru from '../locales/ru'; const faker = new Faker({ - locale: 'ru', - localeFallback: 'en', + localeOrder: ['ru', 'en'], locales: { ru, en, diff --git a/src/locale/sk.ts b/src/locale/sk.ts index ce8bc05a547..03db55e6197 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import sk from '../locales/sk'; const faker = new Faker({ - locale: 'sk', - localeFallback: 'en', + localeOrder: ['sk', 'en'], locales: { sk, en, diff --git a/src/locale/sv.ts b/src/locale/sv.ts index 30706dfa8a1..8ccb462e4a9 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import sv from '../locales/sv'; const faker = new Faker({ - locale: 'sv', - localeFallback: 'en', + localeOrder: ['sv', 'en'], locales: { sv, en, diff --git a/src/locale/tr.ts b/src/locale/tr.ts index c68fe76f156..3af821b09a4 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import tr from '../locales/tr'; const faker = new Faker({ - locale: 'tr', - localeFallback: 'en', + localeOrder: ['tr', 'en'], locales: { tr, en, diff --git a/src/locale/uk.ts b/src/locale/uk.ts index a6b1c1bc1dd..480657aae9a 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import uk from '../locales/uk'; const faker = new Faker({ - locale: 'uk', - localeFallback: 'en', + localeOrder: ['uk', 'en'], locales: { uk, en, diff --git a/src/locale/ur.ts b/src/locale/ur.ts index 249c4011b9c..5214a0aa91f 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import ur from '../locales/ur'; const faker = new Faker({ - locale: 'ur', - localeFallback: 'en', + localeOrder: ['ur', 'en'], locales: { ur, en, diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 62c1e367f96..8664f0a5614 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import vi from '../locales/vi'; const faker = new Faker({ - locale: 'vi', - localeFallback: 'en', + localeOrder: ['vi', 'en'], locales: { vi, en, diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index d7fddf293e5..78ae2c86d65 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import zh_CN from '../locales/zh_CN'; const faker = new Faker({ - locale: 'zh_CN', - localeFallback: 'en', + localeOrder: ['zh_CN', 'en'], locales: { zh_CN, en, diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index 5a9b3e31583..33682852e2d 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import zh_TW from '../locales/zh_TW'; const faker = new Faker({ - locale: 'zh_TW', - localeFallback: 'en', + localeOrder: ['zh_TW', 'en'], locales: { zh_TW, en, diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index f75bf2871f1..d2cbfb1f5ce 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -8,8 +8,7 @@ import en from '../locales/en'; import zu_ZA from '../locales/zu_ZA'; const faker = new Faker({ - locale: 'zu_ZA', - localeFallback: 'en', + localeOrder: ['zu_ZA', 'en'], locales: { zu_ZA, en, diff --git a/test/address.spec.ts b/test/address.spec.ts index 8007714568a..e71c14c16dd 100644 --- a/test/address.spec.ts +++ b/test/address.spec.ts @@ -98,7 +98,7 @@ const NON_SEEDED_BASED_RUN = 5; describe('address', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { @@ -383,7 +383,7 @@ describe('address', () => { it('returns zipCode with proper locale format', () => { // we'll use the en_CA locale.. - faker.locale = 'en_CA'; + faker.localeOrder = ['en_CA']; const zipCode = faker.address.zipCode(); expect(zipCode).match(/^[A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d$/); @@ -392,7 +392,7 @@ describe('address', () => { describe('zipCodeByState()', () => { it('returns zipCode valid for specified State', () => { - faker.locale = 'en_US'; + faker.localeOrder = ['en_US']; const states = ['IL', 'GA', 'WA']; const zipCode1 = +faker.address.zipCodeByState(states[0]); diff --git a/test/all_functional.spec.ts b/test/all_functional.spec.ts index 756749afdc9..7e11b8bb5a3 100644 --- a/test/all_functional.spec.ts +++ b/test/all_functional.spec.ts @@ -72,7 +72,7 @@ describe('functional tests', () => { describe(module, () => { modules[module].forEach((meth) => { const testAssertion = () => { - faker.locale = locale; + faker.setLocale(locale); // TODO ST-DDT 2022-03-28: Use random seed once there are no more failures faker.seed(1); const result = faker[module][meth](); @@ -105,7 +105,7 @@ describe('faker.fake functional tests', () => { describe(module, () => { modules[module].forEach((meth) => { it(`${meth}()`, () => { - faker.locale = locale; + faker.setLocale(locale); // TODO ST-DDT 2022-03-28: Use random seed once there are no more failures faker.seed(1); const result = faker.fake(`{{${module}.${meth}}}`); diff --git a/test/animal.spec.ts b/test/animal.spec.ts index b98aae5004b..81ca4d5e63b 100644 --- a/test/animal.spec.ts +++ b/test/animal.spec.ts @@ -82,7 +82,7 @@ const functionNames = [ describe('animal', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/commerce.spec.ts b/test/commerce.spec.ts index 64c7d7b324d..4bc5939adbf 100644 --- a/test/commerce.spec.ts +++ b/test/commerce.spec.ts @@ -61,7 +61,7 @@ const functionNames = [ describe('commerce', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/company.spec.ts b/test/company.spec.ts index 7b8e7820dd2..aac95c20d4e 100644 --- a/test/company.spec.ts +++ b/test/company.spec.ts @@ -70,7 +70,7 @@ const functionNames = [ describe('company', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/database.spec.ts b/test/database.spec.ts index 053f91d9f9f..6aa0e43c0d4 100644 --- a/test/database.spec.ts +++ b/test/database.spec.ts @@ -46,7 +46,7 @@ const functionNames = [ describe('database', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/date.spec.ts b/test/date.spec.ts index 99141a89476..67001cc11fa 100644 --- a/test/date.spec.ts +++ b/test/date.spec.ts @@ -113,7 +113,7 @@ const NON_SEEDED_BASED_RUN = 5; describe('date', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/faker.spec.ts b/test/faker.spec.ts index d8ca61c8094..a7b5a02a948 100644 --- a/test/faker.spec.ts +++ b/test/faker.spec.ts @@ -4,7 +4,7 @@ import { FakerError } from '../src/errors/faker-error'; describe('faker', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should throw error if no options passed', () => { @@ -34,14 +34,14 @@ describe('faker', () => { describe('definitions', () => { describe('title', () => { it.each(Object.keys(faker.locales))('title (%s)', (locale) => { - faker.locale = locale; + faker.localeOrder = [locale]; expect(faker.definitions.title).toBe(faker.locales[locale].title); }); }); describe('separator', () => { it.each(Object.keys(faker.locales))('separator (%s)', (locale) => { - faker.locale = locale; + faker.setLocale(locale); expect(faker.definitions.separator).toBeTypeOf('string'); }); diff --git a/test/finance.spec.ts b/test/finance.spec.ts index 2052d4235a7..49f5d771b45 100644 --- a/test/finance.spec.ts +++ b/test/finance.spec.ts @@ -104,7 +104,7 @@ const NON_SEEDED_BASED_RUN = 5; describe('finance', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seedRuns) { diff --git a/test/git.spec.ts b/test/git.spec.ts index 84f85e760d0..bdeb167d13b 100644 --- a/test/git.spec.ts +++ b/test/git.spec.ts @@ -77,7 +77,7 @@ const functionNames = [ describe('git', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/hacker.spec.ts b/test/hacker.spec.ts index 1a567588aee..42af9955f49 100644 --- a/test/hacker.spec.ts +++ b/test/hacker.spec.ts @@ -89,7 +89,7 @@ const functionNames = [ describe('name', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { @@ -114,7 +114,7 @@ describe('name', () => { for (let i = 1; i <= NON_SEEDED_BASED_RUN; i++) { describe('abbreviation()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random abbreviation from array', () => { @@ -128,7 +128,7 @@ describe('name', () => { describe('adjective', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random adjective from array', () => { @@ -142,7 +142,7 @@ describe('name', () => { describe('noun', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random noun from array', () => { @@ -156,7 +156,7 @@ describe('name', () => { describe('verb', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random verb from array', () => { @@ -170,7 +170,7 @@ describe('name', () => { describe('ingverb', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random ingverb from array', () => { @@ -184,7 +184,7 @@ describe('name', () => { describe('phrase', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random phrase from array', () => { diff --git a/test/helpers.spec.ts b/test/helpers.spec.ts index 9f81e20191f..49a5a2993cb 100644 --- a/test/helpers.spec.ts +++ b/test/helpers.spec.ts @@ -474,7 +474,7 @@ const functionNames = [ describe('helpers', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/internet.spec.ts b/test/internet.spec.ts index a16ee39f0d8..ce5d4c966d1 100644 --- a/test/internet.spec.ts +++ b/test/internet.spec.ts @@ -106,7 +106,7 @@ const functionNames = [ describe('internet', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/locale-imports.spec.ts b/test/locale-imports.spec.ts index 6ac66fae3d0..b5b4ec422dc 100644 --- a/test/locale-imports.spec.ts +++ b/test/locale-imports.spec.ts @@ -8,7 +8,8 @@ describe('locale imports', () => { const faker = require(`../dist/cjs/locale/${locale}`); expect(faker).toBeDefined(); - expect(faker.locale).toBe(locale); + expect(faker.localeOrder[0]).toBe(locale); + expect(faker.localeOrder[faker.localeOrder.length - 1]).toBe('en'); }); // Internal test to cover `src/locale/*.ts` @@ -17,7 +18,8 @@ describe('locale imports', () => { const faker = require(`../locale/${locale}`); expect(faker).toBeDefined(); - expect(faker.locale).toBe(locale); + expect(faker.localeOrder[0]).toBe(locale); + expect(faker.localeOrder[faker.localeOrder.length - 1]).toBe('en'); }); } }); diff --git a/test/locales.spec.ts b/test/locales.spec.ts index eb805d96632..4e77fc84f94 100644 --- a/test/locales.spec.ts +++ b/test/locales.spec.ts @@ -8,7 +8,8 @@ describe('locale', () => { it('setLocale() changes faker.locale', () => { for (const locale in faker.locales) { faker.setLocale(locale); - expect(faker.locale).toBe(locale); + expect(faker.localeOrder[0]).toBe(locale); + expect(faker.localeOrder[faker.localeOrder.length - 1]).toBe('en'); } }); }); diff --git a/test/lorem.spec.ts b/test/lorem.spec.ts index 1f2dbc5b22f..495a2ec57ae 100644 --- a/test/lorem.spec.ts +++ b/test/lorem.spec.ts @@ -99,7 +99,7 @@ const functionNames = [ describe('lorem', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/music.spec.ts b/test/music.spec.ts index 73457e8dbcd..2acdce59d7f 100644 --- a/test/music.spec.ts +++ b/test/music.spec.ts @@ -34,7 +34,7 @@ const NON_SEEDED_BASED_RUN = 5; describe('music', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/name.spec.ts b/test/name.spec.ts index 97ac7fbacb3..0e35f41216a 100644 --- a/test/name.spec.ts +++ b/test/name.spec.ts @@ -146,7 +146,7 @@ const functionNames = [ describe('name', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -172,7 +172,7 @@ describe('name', () => { for (let i = 1; i <= NON_SEEDED_BASED_RUN; i++) { describe('firstName()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -210,8 +210,7 @@ describe('name', () => { }); it('should return a gender-specific first name when no gender-specific first name was defined', () => { - faker.locale = 'az'; - faker.localeFallback = 'az'; + faker.localeOrder = ['az']; const name = faker.name.firstName(); expect([ @@ -223,8 +222,7 @@ describe('name', () => { describe('lastName()', () => { beforeEach(() => { - faker.locale = 'en'; - faker.localeFallback = 'en'; + faker.localeOrder = ['en']; }); it('should return a random last name', () => { @@ -235,7 +233,7 @@ describe('name', () => { }); it('should return a gender-specific last name when passed a number', () => { - faker.locale = 'az'; + faker.localeOrder = ['az']; const spy = vi.spyOn(console, 'warn'); @@ -255,7 +253,7 @@ describe('name', () => { }); it('should return a gender-specific last name when passed a string', () => { - faker.locale = 'az'; + faker.localeOrder = ['az']; let name = faker.name.lastName('female'); expect(faker.definitions.name.female_last_name).toContain(name); @@ -267,7 +265,7 @@ describe('name', () => { describe('middleName()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -279,7 +277,7 @@ describe('name', () => { }); it('should return a middle name when passed en locale', () => { - faker.locale = 'en'; + faker.localeOrder = ['en']; let name = faker.name.middleName(); expect(faker.definitions.name.middle_name).toContain(name); @@ -294,7 +292,7 @@ describe('name', () => { it('should return a gender-specific middle name when passed a number', () => { const spy = vi.spyOn(console, 'warn'); - faker.locale = 'uk'; + faker.localeOrder = ['uk']; let name = faker.name.middleName(0); expect(faker.definitions.name.male_middle_name).toContain(name); @@ -312,7 +310,7 @@ describe('name', () => { }); it('should return a gender-specific middle name when passed a string', () => { - faker.locale = 'uk'; + faker.localeOrder = ['uk']; let name = faker.name.middleName('female'); expect(faker.definitions.name.female_middle_name).toContain(name); @@ -324,7 +322,7 @@ describe('name', () => { describe('findName()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -336,7 +334,7 @@ describe('name', () => { }); it('should return a female gender-specific name with firstName and lastName', () => { - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const female_specific = [ ...faker.definitions.name.female_prefix, @@ -354,7 +352,7 @@ describe('name', () => { }); it('should return a male gender-specific name with firstName and lastName', () => { - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const male_specific = [ ...faker.definitions.name.male_prefix, @@ -372,7 +370,7 @@ describe('name', () => { }); it('should return a female gender-specific name with given firstName and lastName', () => { - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const male_specific = [ ...faker.definitions.name.female_prefix, @@ -394,7 +392,7 @@ describe('name', () => { }); it('should return a male gender-specific name with given firstName and lastName', () => { - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const male_specific = [ ...faker.definitions.name.male_prefix, @@ -414,7 +412,7 @@ describe('name', () => { describe('gender()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -435,7 +433,7 @@ describe('name', () => { describe('prefix()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -447,7 +445,7 @@ describe('name', () => { }); it('should return a female prefix with given string', () => { - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const prefix = faker.name.prefix('female'); @@ -456,7 +454,7 @@ describe('name', () => { }); it('should return a male prefix with given string', () => { - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const prefix = faker.name.prefix('male'); @@ -467,7 +465,7 @@ describe('name', () => { it('should return a male prefix with given number', () => { const spy = vi.spyOn(console, 'warn'); - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const prefix = faker.name.prefix(0); @@ -484,7 +482,7 @@ describe('name', () => { it('should return a female prefix with given number', () => { const spy = vi.spyOn(console, 'warn'); - faker.locale = 'mk'; + faker.localeOrder = ['mk']; const prefix = faker.name.prefix(1); @@ -501,7 +499,7 @@ describe('name', () => { describe('suffix()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -515,7 +513,7 @@ describe('name', () => { describe('title()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -556,7 +554,7 @@ describe('name', () => { describe('jobTitle()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -575,7 +573,7 @@ describe('name', () => { describe('jobDescriptor()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -590,7 +588,7 @@ describe('name', () => { describe('jobArea()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); @@ -605,7 +603,7 @@ describe('name', () => { describe('jobType()', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; faker.localeFallback = 'en'; }); diff --git a/test/phone.spec.ts b/test/phone.spec.ts index 162de0311c6..2860dc0916c 100644 --- a/test/phone.spec.ts +++ b/test/phone.spec.ts @@ -70,7 +70,7 @@ const NON_SEEDED_BASED_RUN = 25; describe('phone', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { @@ -116,19 +116,19 @@ describe('phone', () => { describe('phoneNumberFormat()', () => { it('should return phone number with proper US format (Array index)', () => { - faker.locale = 'en'; + faker.localeOrder = ['en']; const phoneNumber = faker.phone.phoneNumberFormat(1); expect(phoneNumber).match(/\([2-9]\d\d\) [2-9]\d\d-\d\d\d\d/); }); it('should return phone number with proper CA format (Array index)', () => { - faker.locale = 'en_CA'; + faker.localeOrder = ['en_CA']; const phoneNumber = faker.phone.phoneNumberFormat(1); expect(phoneNumber).match(/\([2-9]\d\d\)[2-9]\d\d-\d\d\d\d/); }); it('should return phone number with proper PL format (Array index)', () => { - faker.locale = 'pl'; + faker.localeOrder = ['pl']; const phoneNumber = faker.phone.phoneNumberFormat(1); expect(phoneNumber).match(/13-\d{3}-\d{2}-\d{2}/); }); diff --git a/test/random.spec.ts b/test/random.spec.ts index 886284cde74..d4acd9cc670 100644 --- a/test/random.spec.ts +++ b/test/random.spec.ts @@ -105,7 +105,7 @@ describe('random', () => { ]; beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return a random word', () => { @@ -129,7 +129,7 @@ describe('random', () => { it.each(times(50))( 'should only contain a word without undesirable non-alpha characters, locale=zh_CN (run %i)', () => { - faker.locale = 'zh_CN'; + faker.setLocale('zh_CN'); const actual = faker.random.word(); @@ -142,7 +142,7 @@ describe('random', () => { describe('words', () => { beforeEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('should return random words', () => { diff --git a/test/system.spec.ts b/test/system.spec.ts index 5eec52b4442..697682b79bb 100644 --- a/test/system.spec.ts +++ b/test/system.spec.ts @@ -67,7 +67,7 @@ const functionNames = [ describe('system', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { @@ -272,7 +272,7 @@ describe('system', () => { describe('extra tests', () => { describe('commonFileName()', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); it('#770', () => { diff --git a/test/unique.spec.ts b/test/unique.spec.ts index 6f26a0c5067..af6b76ac1d5 100644 --- a/test/unique.spec.ts +++ b/test/unique.spec.ts @@ -43,7 +43,7 @@ function customMethod(prefix: string = ''): string { describe('unique', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/vehicle.spec.ts b/test/vehicle.spec.ts index 28757e6b03a..39f187000c5 100644 --- a/test/vehicle.spec.ts +++ b/test/vehicle.spec.ts @@ -62,7 +62,7 @@ const functionNames = [ describe('vehicle', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) { diff --git a/test/word.spec.ts b/test/word.spec.ts index d236f564a0c..da4297467c4 100644 --- a/test/word.spec.ts +++ b/test/word.spec.ts @@ -138,7 +138,7 @@ const functionNames = [ describe('word', () => { afterEach(() => { - faker.locale = 'en'; + faker.localeOrder = ['en']; }); for (const { seed, expectations } of seededRuns) {