Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(locale)!: remove location data index-value-binding #2476

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/definitions/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,31 @@
* 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 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[];
};

Check warning on line 92 in src/definitions/location.ts

View check run for this annotation

Codecov / codecov/patch

src/definitions/location.ts#L68-L92

Added lines #L68 - L92 were not covered by tests

/**
* The abbreviated names of the compass directions.
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
16 changes: 6 additions & 10 deletions src/locales/da/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
1 change: 0 additions & 1 deletion src/locales/da/location/direction_abbr.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/locales/da/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import city_pattern from './city_pattern';
import country from './country';
import default_country from './default_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';
Expand All @@ -23,7 +22,6 @@ const location: LocationDefinition = {
country,
default_country,
direction,
direction_abbr,
postcode,
secondary_address,
street_address,
Expand Down
16 changes: 6 additions & 10 deletions src/locales/en/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
1 change: 0 additions & 1 deletion src/locales/en/location/direction_abbr.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/locales/en/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import country from './country';
import county from './county';
import default_country from './default_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';
Expand All @@ -32,7 +31,6 @@ const location: LocationDefinition = {
county,
default_country,
direction,
direction_abbr,
postcode,
secondary_address,
state,
Expand Down
16 changes: 6 additions & 10 deletions src/locales/eo/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
1 change: 0 additions & 1 deletion src/locales/eo/location/direction_abbr.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/locales/eo/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import city_suffix from './city_suffix';
import country from './country';
import default_country from './default_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';
Expand All @@ -23,7 +22,6 @@ const location: LocationDefinition = {
country,
default_country,
direction,
direction_abbr,
secondary_address,
street_address,
street_pattern,
Expand Down
16 changes: 6 additions & 10 deletions src/locales/fa/location/direction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export default [
'شمال',
'شرق',
'جنوب',
'غرب',
'شمال شرق',
'شمال غرب',
'جنوب شرق',
'جنوب غرب',
];
export default {
cardinal: ['شمال', 'شرق', 'جنوب', 'غرب'],
cardinal_abbr: ['شمالی', 'شرقی', 'جنوبی', 'غربی'],
ordinal: ['شمال شرق', 'شمال غرب', 'جنوب شرق', 'جنوب غرب'],
ordinal_abbr: ['شمال شرق', 'شمال غرب', 'جنوب شرق', 'جنوب غرب'],
};
16 changes: 6 additions & 10 deletions src/locales/fr/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
16 changes: 6 additions & 10 deletions src/locales/fr_CH/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
16 changes: 6 additions & 10 deletions src/locales/he/location/direction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export default [
'צפון',
'מזרח',
'דרום',
'מערב',
'צפון מזרח',
'צפון מערב',
'דרום מזרח',
'דרום מערב',
];
export default {
cardinal: ['צפון', 'מזרח', 'דרום', 'מערב'],
cardinal_abbr: ['צ', 'מז', 'ד', 'מע'],
ordinal: ['צפון מזרח', 'צפון מערב', 'דרום מזרח', 'דרום מערב'],
ordinal_abbr: ['צ-מז', 'צ-מע', 'ד-מז', 'ד-מע'],
};
1 change: 0 additions & 1 deletion src/locales/he/location/direction_abbr.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/locales/he/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import country from './country';
import county from './county';
import default_country from './default_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';
Expand All @@ -28,7 +27,6 @@ const location: LocationDefinition = {
county,
default_country,
direction,
direction_abbr,
postcode,
secondary_address,
state,
Expand Down
26 changes: 16 additions & 10 deletions src/locales/hy/location/direction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
export default [
'Հյուսիսային',
'Արևելյան',
'Հարավային',
'Արևմտյան',
'Հյուսիսարևելյան',
'Հյուսիսարևմտյան',
'Հարավարևելյան',
'Հարավարևմտյան',
];
export default {
cardinal: ['Հյուսիսային', 'Արևելյան', 'Հարավային', 'Արևմտյան'],
cardinal_abbr: ['հս․ լ․', 'ավ․ ե․', 'հվ․ լ․', 'ամ․ ե․'],
ordinal: [
'Հյուսիսարևելյան',
'Հյուսիսարևմտյան',
'Հարավարևելյան',
'Հարավարևմտյան',
],
ordinal_abbr: [
'հս․ լ․ ավ․ ե․',
'հս․ լ․ ամ․ ե․',
'հվ․ լ․ ավ․ ե․',
'հվ․ լ․ ամ․ ե․',
],
};
7 changes: 6 additions & 1 deletion src/locales/ja/location/direction.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export default ['北', '東', '南', '西', '北東', '北西', '南東', '南西'];
export default {
cardinal: ['北', '東', '南', '西'],
cardinal_abbr: ['北', '東', '南', '西'],
ordinal: ['北東', '北西', '南東', '南西'],
ordinal_abbr: ['北東', '北西', '南東', '南西'],
};
21 changes: 11 additions & 10 deletions src/locales/pl/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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.'],
};
11 changes: 0 additions & 11 deletions src/locales/pl/location/direction_abbr.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/locales/pl/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import city_pattern from './city_pattern';
import country from './country';
import default_country from './default_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';
Expand All @@ -25,7 +24,6 @@ const location: LocationDefinition = {
country,
default_country,
direction,
direction_abbr,
postcode,
secondary_address,
state,
Expand Down
16 changes: 6 additions & 10 deletions src/locales/pt_PT/location/direction.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
16 changes: 6 additions & 10 deletions src/locales/ur/location/direction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export default [
'شمال',
'مشرق',
'جنوب',
'مغرب',
'شمال مشرق',
'سمال مغرب',
'جنوب مشرق',
'جنوب مغرب',
];
export default {
cardinal: ['شمال', 'مشرق', 'جنوب', 'مغرب'],
cardinal_abbr: ['شمال', 'مشرق', 'جنوب', 'مغرب'],
ordinal: ['شمال مشرق', 'سمال مغرب', 'جنوب مشرق', 'جنوب مغرب'],
ordinal_abbr: ['شمال مشرق', 'سمال مغرب', 'جنوب مشرق', 'جنوب مغرب'],
};
22 changes: 12 additions & 10 deletions src/modules/location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,14 +844,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,
]);
}

/**
Expand Down Expand Up @@ -957,12 +959,12 @@ export class LocationModule extends ModuleBase {
const { abbreviated = false } = options;
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
);
}

Expand Down Expand Up @@ -1069,12 +1071,12 @@ export class LocationModule extends ModuleBase {
const { abbreviated = false } = options;
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
);
}

Expand Down
Loading