aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/guide/upgrading_v9/2476.md12
-rw-r--r--src/definitions/location.ts30
-rw-r--r--src/locales/da/location/direction.ts16
-rw-r--r--src/locales/da/location/direction_abbr.ts1
-rw-r--r--src/locales/da/location/index.ts2
-rw-r--r--src/locales/en/location/direction.ts16
-rw-r--r--src/locales/en/location/direction_abbr.ts1
-rw-r--r--src/locales/en/location/index.ts2
-rw-r--r--src/locales/eo/location/direction.ts16
-rw-r--r--src/locales/eo/location/direction_abbr.ts1
-rw-r--r--src/locales/eo/location/index.ts2
-rw-r--r--src/locales/fa/location/direction.ts16
-rw-r--r--src/locales/fr/location/direction.ts16
-rw-r--r--src/locales/fr_CH/location/direction.ts16
-rw-r--r--src/locales/he/location/direction.ts16
-rw-r--r--src/locales/he/location/direction_abbr.ts1
-rw-r--r--src/locales/he/location/index.ts2
-rw-r--r--src/locales/hy/location/direction.ts26
-rw-r--r--src/locales/ja/location/direction.ts7
-rw-r--r--src/locales/pl/location/direction.ts21
-rw-r--r--src/locales/pl/location/direction_abbr.ts11
-rw-r--r--src/locales/pl/location/index.ts2
-rw-r--r--src/locales/pt_PT/location/direction.ts16
-rw-r--r--src/locales/ur/location/direction.ts16
-rw-r--r--src/locales/uz_UZ_latin/location/direction.ts26
-rw-r--r--src/modules/location/index.ts22
26 files changed, 151 insertions, 162 deletions
diff --git a/docs/guide/upgrading_v9/2476.md b/docs/guide/upgrading_v9/2476.md
new file mode 100644
index 00000000..b1ee78f8
--- /dev/null
+++ b/docs/guide/upgrading_v9/2476.md
@@ -0,0 +1,12 @@
+### Direction definitions reorganized
+
+The locale definitions used by `faker.location.direction()`, `faker.location.cardinalDirection()` and `faker.location.ordinalDirection()` have been reorganized.
+Previously, they were organized under `definitions.location.direction` and `definitions.location.direction_abbr` and where values were required to be in a specific order.
+Now, all values are nested under `definitions.location.direction` with descriptive property names.
+If you are using the public methods, no changes are required.
+You only need to change your code if you are accessing the raw definitions e.g. in `faker.helpers.fake()`.
+
+| Before | After |
+| ------------------------- | ----------------------------------------------------------------------- |
+| `location.direction` | `location.direction.cardinal` or `location.direction.ordinal` |
+| `location.direction_abbr` | `location.direction.cardinal_abbr` or `location.direction.ordinal_abbr` |
diff --git a/src/definitions/location.ts b/src/definitions/location.ts
index 42d79c01..1814a3ac 100644
--- a/src/definitions/location.ts
+++ b/src/definitions/location.ts
@@ -65,13 +65,31 @@ export type LocationDefinition = LocaleEntry<{
* The names of the compass directions.
* First the 4 cardinal directions, then the 4 ordinal directions.
*/
- direction: string[];
+ direction: {
+ /**
+ * The names of the cardinal compass directions.
+ * Cardinal directions are the four main points of a compass.
+ */
+ cardinal: string[];
- /**
- * The abbreviated names of the compass directions.
- * First the 4 cardinal directions, then the 4 ordinal directions.
- */
- direction_abbr: string[];
+ /**
+ * The abbreviated names of the cardinal compass directions.
+ * Cardinal directions are the four main points of a compass.
+ */
+ cardinal_abbr: string[];
+
+ /**
+ * The names of ordinal compass directions.
+ * Ordinal directions are combinations of cardinal directions.
+ */
+ ordinal: string[];
+
+ /**
+ * The abbreviated names of ordinal compass directions.
+ * Ordinal directions are combinations of cardinal directions.
+ */
+ ordinal_abbr: string[];
+ };
/**
* The pattern used to generate building numbers. Since building numbers rarely start with 0, any consecutive # characters will be replaced by a number without a leading zero.
diff --git a/src/locales/da/location/direction.ts b/src/locales/da/location/direction.ts
index bee4196e..eed01ac2 100644
--- a/src/locales/da/location/direction.ts
+++ b/src/locales/da/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'Nord',
- 'Øst',
- 'Syd',
- 'Vest',
- 'Nordøst',
- 'Nordvest',
- 'Sydøst',
- 'Sydvest',
-];
+export default {
+ cardinal: ['Nord', 'Øst', 'Syd', 'Vest'],
+ cardinal_abbr: ['N', 'Ø', 'S', 'V'],
+ ordinal: ['Nordøst', 'Nordvest', 'Sydøst', 'Sydvest'],
+ ordinal_abbr: ['NØ', 'NV', 'SØ', 'SV'],
+};
diff --git a/src/locales/da/location/direction_abbr.ts b/src/locales/da/location/direction_abbr.ts
deleted file mode 100644
index bdf4fa96..00000000
--- a/src/locales/da/location/direction_abbr.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['N', 'Ø', 'S', 'V', 'NØ', 'NV', 'SØ', 'SV'];
diff --git a/src/locales/da/location/index.ts b/src/locales/da/location/index.ts
index 7f846e46..d0fe278c 100644
--- a/src/locales/da/location/index.ts
+++ b/src/locales/da/location/index.ts
@@ -8,7 +8,6 @@ import city_name from './city_name';
import city_pattern from './city_pattern';
import country from './country';
import direction from './direction';
-import direction_abbr from './direction_abbr';
import postcode from './postcode';
import secondary_address from './secondary_address';
import street_address from './street_address';
@@ -21,7 +20,6 @@ const location: LocationDefinition = {
city_pattern,
country,
direction,
- direction_abbr,
postcode,
secondary_address,
street_address,
diff --git a/src/locales/en/location/direction.ts b/src/locales/en/location/direction.ts
index 07712e80..79f0a823 100644
--- a/src/locales/en/location/direction.ts
+++ b/src/locales/en/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'North',
- 'East',
- 'South',
- 'West',
- 'Northeast',
- 'Northwest',
- 'Southeast',
- 'Southwest',
-];
+export default {
+ cardinal: ['North', 'East', 'South', 'West'],
+ cardinal_abbr: ['N', 'E', 'S', 'W'],
+ ordinal: ['Northeast', 'Northwest', 'Southeast', 'Southwest'],
+ ordinal_abbr: ['NE', 'NW', 'SE', 'SW'],
+};
diff --git a/src/locales/en/location/direction_abbr.ts b/src/locales/en/location/direction_abbr.ts
deleted file mode 100644
index 03f085ad..00000000
--- a/src/locales/en/location/direction_abbr.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['N', 'E', 'S', 'W', 'NE', 'NW', 'SE', 'SW'];
diff --git a/src/locales/en/location/index.ts b/src/locales/en/location/index.ts
index 1459ecf0..7938321d 100644
--- a/src/locales/en/location/index.ts
+++ b/src/locales/en/location/index.ts
@@ -11,7 +11,6 @@ import city_suffix from './city_suffix';
import country from './country';
import county from './county';
import direction from './direction';
-import direction_abbr from './direction_abbr';
import postcode from './postcode';
import secondary_address from './secondary_address';
import state from './state';
@@ -30,7 +29,6 @@ const location: LocationDefinition = {
country,
county,
direction,
- direction_abbr,
postcode,
secondary_address,
state,
diff --git a/src/locales/eo/location/direction.ts b/src/locales/eo/location/direction.ts
index 49d1a497..87e430e9 100644
--- a/src/locales/eo/location/direction.ts
+++ b/src/locales/eo/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'nordo',
- 'oriento',
- 'sudo',
- 'okcidento',
- 'nordoriento',
- 'nordokcidenta',
- 'sudoriento',
- 'sudokcidento',
-];
+export default {
+ cardinal: ['nordo', 'oriento', 'sudo', 'okcidento'],
+ cardinal_abbr: ['N', 'E', 'S', 'U'],
+ ordinal: ['nordoriento', 'nordokcidenta', 'sudoriento', 'sudokcidento'],
+ ordinal_abbr: ['NE', 'NU', 'SE', 'SU'],
+};
diff --git a/src/locales/eo/location/direction_abbr.ts b/src/locales/eo/location/direction_abbr.ts
deleted file mode 100644
index 9f677a36..00000000
--- a/src/locales/eo/location/direction_abbr.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['N', 'E', 'S', 'U', 'NE', 'NU', 'SE', 'SU'];
diff --git a/src/locales/eo/location/index.ts b/src/locales/eo/location/index.ts
index 1d089079..ef54c162 100644
--- a/src/locales/eo/location/index.ts
+++ b/src/locales/eo/location/index.ts
@@ -8,7 +8,6 @@ import city_prefix from './city_prefix';
import city_suffix from './city_suffix';
import country from './country';
import direction from './direction';
-import direction_abbr from './direction_abbr';
import secondary_address from './secondary_address';
import street_address from './street_address';
import street_pattern from './street_pattern';
@@ -21,7 +20,6 @@ const location: LocationDefinition = {
city_suffix,
country,
direction,
- direction_abbr,
secondary_address,
street_address,
street_pattern,
diff --git a/src/locales/fa/location/direction.ts b/src/locales/fa/location/direction.ts
index 2fe64b35..c8c29ce8 100644
--- a/src/locales/fa/location/direction.ts
+++ b/src/locales/fa/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'شمال',
- 'شرق',
- 'جنوب',
- 'غرب',
- 'شمال شرق',
- 'شمال غرب',
- 'جنوب شرق',
- 'جنوب غرب',
-];
+export default {
+ cardinal: ['شمال', 'شرق', 'جنوب', 'غرب'],
+ cardinal_abbr: ['شمالی', 'شرقی', 'جنوبی', 'غربی'],
+ ordinal: ['شمال شرق', 'شمال غرب', 'جنوب شرق', 'جنوب غرب'],
+ ordinal_abbr: ['شمال شرق', 'شمال غرب', 'جنوب شرق', 'جنوب غرب'],
+};
diff --git a/src/locales/fr/location/direction.ts b/src/locales/fr/location/direction.ts
index b58942c3..fd6c6852 100644
--- a/src/locales/fr/location/direction.ts
+++ b/src/locales/fr/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'Nord',
- 'Est',
- 'Sud',
- 'Ouest',
- 'Nord-est',
- 'Nord-ouest',
- 'Sud-est',
- 'Sud-ouest',
-];
+export default {
+ cardinal: ['Nord', 'Est', 'Sud', 'Ouest'],
+ cardinal_abbr: ['N', 'E', 'S', 'O'],
+ ordinal: ['Nord-est', 'Nord-ouest', 'Sud-est', 'Sud-ouest'],
+ ordinal_abbr: ['NE', 'NO', 'SE', 'SO'],
+};
diff --git a/src/locales/fr_CH/location/direction.ts b/src/locales/fr_CH/location/direction.ts
index b58942c3..fd6c6852 100644
--- a/src/locales/fr_CH/location/direction.ts
+++ b/src/locales/fr_CH/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'Nord',
- 'Est',
- 'Sud',
- 'Ouest',
- 'Nord-est',
- 'Nord-ouest',
- 'Sud-est',
- 'Sud-ouest',
-];
+export default {
+ cardinal: ['Nord', 'Est', 'Sud', 'Ouest'],
+ cardinal_abbr: ['N', 'E', 'S', 'O'],
+ ordinal: ['Nord-est', 'Nord-ouest', 'Sud-est', 'Sud-ouest'],
+ ordinal_abbr: ['NE', 'NO', 'SE', 'SO'],
+};
diff --git a/src/locales/he/location/direction.ts b/src/locales/he/location/direction.ts
index 3b610358..aae8c116 100644
--- a/src/locales/he/location/direction.ts
+++ b/src/locales/he/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'צפון',
- 'מזרח',
- 'דרום',
- 'מערב',
- 'צפון מזרח',
- 'צפון מערב',
- 'דרום מזרח',
- 'דרום מערב',
-];
+export default {
+ cardinal: ['צפון', 'מזרח', 'דרום', 'מערב'],
+ cardinal_abbr: ['צ', 'מז', 'ד', 'מע'],
+ ordinal: ['צפון מזרח', 'צפון מערב', 'דרום מזרח', 'דרום מערב'],
+ ordinal_abbr: ['צ-מז', 'צ-מע', 'ד-מז', 'ד-מע'],
+};
diff --git a/src/locales/he/location/direction_abbr.ts b/src/locales/he/location/direction_abbr.ts
deleted file mode 100644
index eb5b022b..00000000
--- a/src/locales/he/location/direction_abbr.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default ['צ', 'מז', 'ד', 'מע', 'צ-מז', 'צ-מע', 'ד-מז', 'ד-מע'];
diff --git a/src/locales/he/location/index.ts b/src/locales/he/location/index.ts
index b41044b4..7cb8eab9 100644
--- a/src/locales/he/location/index.ts
+++ b/src/locales/he/location/index.ts
@@ -9,7 +9,6 @@ import city_pattern from './city_pattern';
import country from './country';
import county from './county';
import direction from './direction';
-import direction_abbr from './direction_abbr';
import postcode from './postcode';
import secondary_address from './secondary_address';
import state from './state';
@@ -26,7 +25,6 @@ const location: LocationDefinition = {
country,
county,
direction,
- direction_abbr,
postcode,
secondary_address,
state,
diff --git a/src/locales/hy/location/direction.ts b/src/locales/hy/location/direction.ts
index 07147e91..2a7d5db5 100644
--- a/src/locales/hy/location/direction.ts
+++ b/src/locales/hy/location/direction.ts
@@ -1,10 +1,16 @@
-export default [
- 'Հյուսիսային',
- 'Արևելյան',
- 'Հարավային',
- 'Արևմտյան',
- 'Հյուսիսարևելյան',
- 'Հյուսիսարևմտյան',
- 'Հարավարևելյան',
- 'Հարավարևմտյան',
-];
+export default {
+ cardinal: ['Հյուսիսային', 'Արևելյան', 'Հարավային', 'Արևմտյան'],
+ cardinal_abbr: ['հս․ լ․', 'ավ․ ե․', 'հվ․ լ․', 'ամ․ ե․'],
+ ordinal: [
+ 'Հյուսիսարևելյան',
+ 'Հյուսիսարևմտյան',
+ 'Հարավարևելյան',
+ 'Հարավարևմտյան',
+ ],
+ ordinal_abbr: [
+ 'հս․ լ․ ավ․ ե․',
+ 'հս․ լ․ ամ․ ե․',
+ 'հվ․ լ․ ավ․ ե․',
+ 'հվ․ լ․ ամ․ ե․',
+ ],
+};
diff --git a/src/locales/ja/location/direction.ts b/src/locales/ja/location/direction.ts
index cefead57..2ada99fe 100644
--- a/src/locales/ja/location/direction.ts
+++ b/src/locales/ja/location/direction.ts
@@ -1 +1,6 @@
-export default ['北', '東', '南', '西', '北東', '北西', '南東', '南西'];
+export default {
+ cardinal: ['北', '東', '南', '西'],
+ cardinal_abbr: ['北', '東', '南', '西'],
+ ordinal: ['北東', '北西', '南東', '南西'],
+ ordinal_abbr: ['北東', '北西', '南東', '南西'],
+};
diff --git a/src/locales/pl/location/direction.ts b/src/locales/pl/location/direction.ts
index 08a8dacd..f87e6ccf 100644
--- a/src/locales/pl/location/direction.ts
+++ b/src/locales/pl/location/direction.ts
@@ -1,11 +1,12 @@
// Source: https://pl.wikipedia.org/wiki/Strony_świata
-export default [
- 'północ',
- 'wschód',
- 'południe',
- 'zachód',
- 'północny wschód',
- 'południowy wschód',
- 'południowy zachód',
- 'północny zachód',
-];
+export default {
+ cardinal: ['północ', 'wschód', 'południe', 'zachód'],
+ cardinal_abbr: ['pn.', 'wsch.', 'pd.', 'zach.'],
+ ordinal: [
+ 'północny wschód',
+ 'południowy wschód',
+ 'południowy zachód',
+ 'północny zachód',
+ ],
+ ordinal_abbr: ['pn. wsch.', 'pd. wsch.', 'pd. zach.', 'pn. zach.'],
+};
diff --git a/src/locales/pl/location/direction_abbr.ts b/src/locales/pl/location/direction_abbr.ts
deleted file mode 100644
index 84eb9c07..00000000
--- a/src/locales/pl/location/direction_abbr.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// Source: https://pl.wikipedia.org/wiki/Strony_świata
-export default [
- 'pn.',
- 'wsch.',
- 'pd.',
- 'zach.',
- 'pn. wsch.',
- 'pd. wsch.',
- 'pd. zach.',
- 'pn. zach.',
-];
diff --git a/src/locales/pl/location/index.ts b/src/locales/pl/location/index.ts
index 3610e301..50cd1188 100644
--- a/src/locales/pl/location/index.ts
+++ b/src/locales/pl/location/index.ts
@@ -8,7 +8,6 @@ import city_name from './city_name';
import city_pattern from './city_pattern';
import country from './country';
import direction from './direction';
-import direction_abbr from './direction_abbr';
import postcode from './postcode';
import secondary_address from './secondary_address';
import state from './state';
@@ -23,7 +22,6 @@ const location: LocationDefinition = {
city_pattern,
country,
direction,
- direction_abbr,
postcode,
secondary_address,
state,
diff --git a/src/locales/pt_PT/location/direction.ts b/src/locales/pt_PT/location/direction.ts
index cb310480..d58e5730 100644
--- a/src/locales/pt_PT/location/direction.ts
+++ b/src/locales/pt_PT/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'Norte',
- 'Este',
- 'Sul',
- 'Oeste',
- 'Nordeste',
- 'Noroeste',
- 'Sudeste',
- 'Sodoeste',
-];
+export default {
+ cardinal: ['Norte', 'Este', 'Sul', 'Oeste'],
+ cardinal_abbr: ['N', 'E', 'S', 'O'],
+ ordinal: ['Nordeste', 'Noroeste', 'Sudeste', 'Sodoeste'],
+ ordinal_abbr: ['NE', 'NO', 'SE', 'SO'],
+};
diff --git a/src/locales/ur/location/direction.ts b/src/locales/ur/location/direction.ts
index 83df0c85..a17ba90d 100644
--- a/src/locales/ur/location/direction.ts
+++ b/src/locales/ur/location/direction.ts
@@ -1,10 +1,6 @@
-export default [
- 'شمال',
- 'مشرق',
- 'جنوب',
- 'مغرب',
- 'شمال مشرق',
- 'سمال مغرب',
- 'جنوب مشرق',
- 'جنوب مغرب',
-];
+export default {
+ cardinal: ['شمال', 'مشرق', 'جنوب', 'مغرب'],
+ cardinal_abbr: ['شمال', 'مشرق', 'جنوب', 'مغرب'],
+ ordinal: ['شمال مشرق', 'سمال مغرب', 'جنوب مشرق', 'جنوب مغرب'],
+ ordinal_abbr: ['شمال مشرق', 'سمال مغرب', 'جنوب مشرق', 'جنوب مغرب'],
+};
diff --git a/src/locales/uz_UZ_latin/location/direction.ts b/src/locales/uz_UZ_latin/location/direction.ts
index 5048675f..cb13c5a1 100644
--- a/src/locales/uz_UZ_latin/location/direction.ts
+++ b/src/locales/uz_UZ_latin/location/direction.ts
@@ -1,10 +1,16 @@
-export default [
- 'Shimol',
- 'Sharq',
- 'Janub',
- "G'arb",
- 'Shimoli-sharqiy',
- "Shimoli g'arbiy",
- 'Janubi-sharqiy',
- "Janubi-g'arbiy",
-];
+export default {
+ cardinal: ['Shimol', 'Sharq', 'Janub', "G'arb"],
+ cardinal_abbr: ['Shimol', 'Sharq', 'Janub', "G'arb"],
+ ordinal: [
+ 'Shimoli-sharqiy',
+ "Shimoli g'arbiy",
+ 'Janubi-sharqiy',
+ "Janubi-g'arbiy",
+ ],
+ ordinal_abbr: [
+ 'Shimoli-sharqiy',
+ "Shimoli g'arbiy",
+ 'Janubi-sharqiy',
+ "Janubi-g'arbiy",
+ ],
+};
diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts
index 217fe682..8fbbbe30 100644
--- a/src/modules/location/index.ts
+++ b/src/modules/location/index.ts
@@ -427,14 +427,16 @@ export class LocationModule extends ModuleBase {
const { abbreviated = false } = options;
if (!abbreviated) {
- return this.faker.helpers.arrayElement(
- this.faker.definitions.location.direction
- );
+ return this.faker.helpers.arrayElement([
+ ...this.faker.definitions.location.direction.cardinal,
+ ...this.faker.definitions.location.direction.ordinal,
+ ]);
}
- return this.faker.helpers.arrayElement(
- this.faker.definitions.location.direction_abbr
- );
+ return this.faker.helpers.arrayElement([
+ ...this.faker.definitions.location.direction.cardinal_abbr,
+ ...this.faker.definitions.location.direction.ordinal_abbr,
+ ]);
}
/**
@@ -465,12 +467,12 @@ export class LocationModule extends ModuleBase {
if (!abbreviated) {
return this.faker.helpers.arrayElement(
- this.faker.definitions.location.direction.slice(0, 4)
+ this.faker.definitions.location.direction.cardinal
);
}
return this.faker.helpers.arrayElement(
- this.faker.definitions.location.direction_abbr.slice(0, 4)
+ this.faker.definitions.location.direction.cardinal_abbr
);
}
@@ -502,12 +504,12 @@ export class LocationModule extends ModuleBase {
if (!abbreviated) {
return this.faker.helpers.arrayElement(
- this.faker.definitions.location.direction.slice(4, 8)
+ this.faker.definitions.location.direction.ordinal
);
}
return this.faker.helpers.arrayElement(
- this.faker.definitions.location.direction_abbr.slice(4, 8)
+ this.faker.definitions.location.direction.ordinal_abbr
);
}