diff options
| author | ST-DDT <[email protected]> | 2023-03-07 10:09:29 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-07 09:09:29 +0000 |
| commit | 9a35dc92260585683132172f10bcdec701ed661a (patch) | |
| tree | 35a5711ba5a5fbc18a8f62515d1ae8b25af77023 /src/modules | |
| parent | a4d5203511e6ea7e26bc8c75baf91ee44387cac0 (diff) | |
| download | faker-9a35dc92260585683132172f10bcdec701ed661a.tar.xz faker-9a35dc92260585683132172f10bcdec701ed661a.zip | |
refactor!: remove dynamic locale switching support (#1735)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/location/index.ts | 8 | ||||
| -rw-r--r-- | src/modules/random/index.ts | 16 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts index 2025beac..fb902588 100644 --- a/src/modules/location/index.ts +++ b/src/modules/location/index.ts @@ -72,8 +72,8 @@ export class LocationModule { * If not specified, a random zip code is generated according to the locale's zip format. * * @example - * fakerUS.location.zipCodeByState("AK") // '99595' - * fakerUS.location.zipCodeByState("??") // '47683-9880' + * fakerEN_US.location.zipCodeByState("AK") // '99595' + * fakerEN_US.location.zipCodeByState("??") // '47683-9880' * * @since 8.0.0 */ @@ -107,7 +107,7 @@ export class LocationModule { * * @example * faker.location.city() // 'East Jarretmouth' - * faker.locale = 'de'; faker.location.city() // 'Bad Lilianadorf' + * fakerDE.location.city() // 'Bad Lilianadorf' * * @since 8.0.0 */ @@ -120,7 +120,7 @@ export class LocationModule { * * @example * faker.location.cityName() // 'San Rafael' - * faker.locale = 'de'; faker.location.cityName() // 'Nürnberg' + * fakerDE.location.cityName() // 'Nürnberg' * * @since 8.0.0 */ diff --git a/src/modules/random/index.ts b/src/modules/random/index.ts index bf1c4d22..a2847bbc 100644 --- a/src/modules/random/index.ts +++ b/src/modules/random/index.ts @@ -1,4 +1,5 @@ import type { Faker } from '../..'; +import { FakerError } from '../../errors/faker-error'; import { deprecated } from '../../internal/deprecated'; import type { LiteralUnion } from '../../utils/types'; import type { @@ -171,16 +172,21 @@ export class RandomModule { } /** - * Returns a random locale, that is available in this faker instance. - * You can use the returned locale with `faker.setLocale(result)`. + * Do NOT use. This property has been removed. * * @example - * faker.random.locale() // 'el' + * faker.helpers.objectKey(allLocales) + * faker.helpers.objectValue(allFakers) * * @since 3.1.0 + * + * @deprecated Use `faker.helpers.objectKey(allLocales/allFakers)` instead. */ - locale(): string { - return this.faker.helpers.arrayElement(Object.keys(this.faker.locales)); + private locale(): never { + // We cannot invoke this ourselves, because this would link to all locale data and increase the bundle size by a lot. + throw new FakerError( + 'This method has been removed. Please use `faker.helpers.objectKey(allLocales/allFakers)` instead.' + ); } /** |
