Skip to content

Commit 453ea97

Browse files
refactor(locale)!: remove location data index-value-binding (#2476)
1 parent 734a7f3 commit 453ea97

26 files changed

Lines changed: 151 additions & 162 deletions

File tree

docs/guide/upgrading_v9/2476.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### Direction definitions reorganized
2+
3+
The locale definitions used by `faker.location.direction()`, `faker.location.cardinalDirection()` and `faker.location.ordinalDirection()` have been reorganized.
4+
Previously, they were organized under `definitions.location.direction` and `definitions.location.direction_abbr` and where values were required to be in a specific order.
5+
Now, all values are nested under `definitions.location.direction` with descriptive property names.
6+
If you are using the public methods, no changes are required.
7+
You only need to change your code if you are accessing the raw definitions e.g. in `faker.helpers.fake()`.
8+
9+
| Before | After |
10+
| ------------------------- | ----------------------------------------------------------------------- |
11+
| `location.direction` | `location.direction.cardinal` or `location.direction.ordinal` |
12+
| `location.direction_abbr` | `location.direction.cardinal_abbr` or `location.direction.ordinal_abbr` |

src/definitions/location.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,31 @@ export type LocationDefinition = LocaleEntry<{
6565
* The names of the compass directions.
6666
* First the 4 cardinal directions, then the 4 ordinal directions.
6767
*/
68-
direction: string[];
68+
direction: {
69+
/**
70+
* The names of the cardinal compass directions.
71+
* Cardinal directions are the four main points of a compass.
72+
*/
73+
cardinal: string[];
6974

70-
/**
71-
* The abbreviated names of the compass directions.
72-
* First the 4 cardinal directions, then the 4 ordinal directions.
73-
*/
74-
direction_abbr: string[];
75+
/**
76+
* The abbreviated names of the cardinal compass directions.
77+
* Cardinal directions are the four main points of a compass.
78+
*/
79+
cardinal_abbr: string[];
80+
81+
/**
82+
* The names of ordinal compass directions.
83+
* Ordinal directions are combinations of cardinal directions.
84+
*/
85+
ordinal: string[];
86+
87+
/**
88+
* The abbreviated names of ordinal compass directions.
89+
* Ordinal directions are combinations of cardinal directions.
90+
*/
91+
ordinal_abbr: string[];
92+
};
7593

7694
/**
7795
* 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.
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
export default [
2-
'Nord',
3-
'Øst',
4-
'Syd',
5-
'Vest',
6-
'Nordøst',
7-
'Nordvest',
8-
'Sydøst',
9-
'Sydvest',
10-
];
1+
export default {
2+
cardinal: ['Nord', 'Øst', 'Syd', 'Vest'],
3+
cardinal_abbr: ['N', 'Ø', 'S', 'V'],
4+
ordinal: ['Nordøst', 'Nordvest', 'Sydøst', 'Sydvest'],
5+
ordinal_abbr: ['NØ', 'NV', 'SØ', 'SV'],
6+
};

src/locales/da/location/direction_abbr.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/locales/da/location/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import city_name from './city_name';
88
import city_pattern from './city_pattern';
99
import country from './country';
1010
import direction from './direction';
11-
import direction_abbr from './direction_abbr';
1211
import postcode from './postcode';
1312
import secondary_address from './secondary_address';
1413
import street_address from './street_address';
@@ -21,7 +20,6 @@ const location: LocationDefinition = {
2120
city_pattern,
2221
country,
2322
direction,
24-
direction_abbr,
2523
postcode,
2624
secondary_address,
2725
street_address,
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
export default [
2-
'North',
3-
'East',
4-
'South',
5-
'West',
6-
'Northeast',
7-
'Northwest',
8-
'Southeast',
9-
'Southwest',
10-
];
1+
export default {
2+
cardinal: ['North', 'East', 'South', 'West'],
3+
cardinal_abbr: ['N', 'E', 'S', 'W'],
4+
ordinal: ['Northeast', 'Northwest', 'Southeast', 'Southwest'],
5+
ordinal_abbr: ['NE', 'NW', 'SE', 'SW'],
6+
};

src/locales/en/location/direction_abbr.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/locales/en/location/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import city_suffix from './city_suffix';
1111
import country from './country';
1212
import county from './county';
1313
import direction from './direction';
14-
import direction_abbr from './direction_abbr';
1514
import postcode from './postcode';
1615
import secondary_address from './secondary_address';
1716
import state from './state';
@@ -30,7 +29,6 @@ const location: LocationDefinition = {
3029
country,
3130
county,
3231
direction,
33-
direction_abbr,
3432
postcode,
3533
secondary_address,
3634
state,
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
export default [
2-
'nordo',
3-
'oriento',
4-
'sudo',
5-
'okcidento',
6-
'nordoriento',
7-
'nordokcidenta',
8-
'sudoriento',
9-
'sudokcidento',
10-
];
1+
export default {
2+
cardinal: ['nordo', 'oriento', 'sudo', 'okcidento'],
3+
cardinal_abbr: ['N', 'E', 'S', 'U'],
4+
ordinal: ['nordoriento', 'nordokcidenta', 'sudoriento', 'sudokcidento'],
5+
ordinal_abbr: ['NE', 'NU', 'SE', 'SU'],
6+
};

src/locales/eo/location/direction_abbr.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)