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

fix(person): change fullName to use name patterns #1637

Merged
merged 28 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
77e0bd4
fix(person): change fullName to use name patterns
matthewmayer Dec 6, 2022
3946178
fix(person): temp disable tests, add gendered prefixes in en
matthewmayer Dec 6, 2022
5c54896
fix(person): fix snapshot tests
matthewmayer Dec 7, 2022
6283b58
fix(person): bring back test
matthewmayer Dec 7, 2022
c285157
fix(person): add weightedArrayElement helper
matthewmayer Dec 7, 2022
753fedc
fix(person): fix nl
matthewmayer Dec 7, 2022
ff786c9
fix(person): fix nl and de_AT
matthewmayer Dec 7, 2022
f462314
fix(person): warnings
matthewmayer Dec 7, 2022
8ecdff5
Merge branch 'next' into chore/fullname-name-patterns
Dec 11, 2022
8abb959
Merge branch 'next' into chore/fullname-name-patterns
matthewmayer Jan 2, 2023
284ad8c
migrate to new weightedArray method
matthewmayer Jan 2, 2023
a802269
rv prefix changes
matthewmayer Jan 2, 2023
9158378
update snapshots
matthewmayer Jan 2, 2023
0a18c4c
fix lint
matthewmayer Jan 2, 2023
f78138c
Merge branch 'next' into chore/fullname-name-patterns
Jan 6, 2023
dd81694
change name patterns to use camelCase
matthewmayer Jan 6, 2023
165224f
remove nobility title prefix for de
matthewmayer Jan 7, 2023
c749b29
Merge branch 'next' into chore/fullname-name-patterns
matthewmayer Jan 10, 2023
93a49ff
Merge branch 'next' into chore/fullname-name-patterns
ST-DDT Jan 10, 2023
6ea472d
revert changes to middle_name in de, de_AT, nl
matthewmayer Jan 28, 2023
4ed2219
Merge branch 'next' into chore/fullname-name-patterns
Jan 28, 2023
b0319d7
rv tussenvoegsel in nl
matthewmayer Jan 28, 2023
d6b6356
parse options first, remove unused gender substitution, update tests
matthewmayer Jan 28, 2023
1c648d6
Merge branch 'next' into chore/fullname-name-patterns
ST-DDT Jan 29, 2023
7826f21
Merge branch 'next' into chore/fullname-name-patterns
ST-DDT Jan 30, 2023
fcff0c1
Merge branch 'next' into chore/fullname-name-patterns
ST-DDT Feb 1, 2023
c3ccd26
fix new lint error
matthewmayer Feb 2, 2023
cea078e
Merge branch 'next' into chore/fullname-name-patterns
ST-DDT Feb 2, 2023
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
9 changes: 3 additions & 6 deletions src/locales/az/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export default [
'{{person.male_first_name}}',
'{{person.male_last_name}} {{person.male_first_name}}',
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.female_first_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}}',
'{{person.first_name}}',
'{{person.last_name}} {{person.first_name}}',
'{{person.first_name}} {{person.last_name}}',
];
9 changes: 3 additions & 6 deletions src/locales/cz/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export default [
'{{person.prefix}} {{person.male_first_name}} {{person.male_last_name}}',
'{{person.prefix}} {{person.female_first_name}} {{person.female_last_name}}',
'{{person.male_first_name}} {{person.male_last_name}} {{person.suffix}}',
'{{person.female_first_name}} {{person.female_last_name}} {{person.suffix}}',
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
];
3 changes: 0 additions & 3 deletions src/locales/de/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.nobility_title_prefix}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
6 changes: 1 addition & 5 deletions src/locales/dv/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export default [
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
];
export default ['{{person.first_name}} {{person.last_name}}'];
1 change: 1 addition & 0 deletions src/locales/en/person/female_prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Mrs.', 'Ms.', 'Miss', 'Dr.'];
4 changes: 4 additions & 0 deletions src/locales/en/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import type { PersonDefinitions } from '../../..';
import female_first_name from './female_first_name';
import female_middle_name from './female_middle_name';
import female_prefix from './female_prefix';
import first_name from './first_name';
import gender from './gender';
import last_name from './last_name';
import male_first_name from './male_first_name';
import male_middle_name from './male_middle_name';
import male_prefix from './male_prefix';
import middle_name from './middle_name';
import name_ from './name';
import prefix from './prefix';
Expand All @@ -21,11 +23,13 @@ import western_zodiac_sign from './western_zodiac_sign';
const person: PersonDefinitions = {
female_first_name,
female_middle_name,
female_prefix,
first_name,
gender,
last_name,
male_first_name,
male_middle_name,
male_prefix,
middle_name,
name: name_,
prefix,
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/person/male_prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Mr.', 'Dr.'];
9 changes: 4 additions & 5 deletions src/locales/en/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
...Array(7).fill('{{person.first_name}} {{person.last_name}}'), //70% of the time we want a first and last name
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
'{{person.prefix}} {{person.first_name}} {{person.last_name}}', //10% of the time add a prefix
'{{person.first_name}} {{person.last_name}} {{person.suffix}}', //10% of the time add a suffix
'{{person.prefix}} {{person.first_name}} {{person.last_name}} {{person.suffix}}', //10% of the time add both
];
6 changes: 2 additions & 4 deletions src/locales/en_GH/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export default [
'{{person.female_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}-{{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}-{{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}-{{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/fa/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
6 changes: 1 addition & 5 deletions src/locales/fi/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export default [
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
export default ['{{person.first_name}} {{person.last_name}}'];
2 changes: 0 additions & 2 deletions src/locales/fr_BE/person/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/he/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/hr/person/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}, {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/hy/person/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
10 changes: 3 additions & 7 deletions src/locales/id_ID/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
export default [
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.male_last_name}} {{person.male_first_name}}',
'{{person.male_first_name}} {{person.male_first_name}} {{person.male_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_first_name}} {{person.male_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}}',
'{{person.female_first_name}} {{person.female_first_name}} {{person.female_last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}}',
'{{person.first_name}} {{person.first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/it/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
17 changes: 6 additions & 11 deletions src/locales/lv/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
export default [
'{{person.prefix}} {{person.male_first_name}} {{person.male_last_name}}',
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.male_last_name}} {{person.male_first_name}}',
'{{person.male_first_name}} {{person.male_first_name}} {{person.male_last_name}}',
'{{person.male_first_name}} {{person.male_last_name}}-{{person.male_last_name}}',
'{{person.prefix}} {{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}} {{person.suffix}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}}',
'{{person.female_first_name}} {{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}}-{{person.female_last_name}}',
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}}',
'{{person.first_name}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}-{{person.last_name}}',
];
6 changes: 2 additions & 4 deletions src/locales/mk/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export default [
'{{person.female_prefix}} {{person.female_first_name}} {{person.female_last_name}}',
'{{person.male_prefix}} {{person.male_first_name}} {{person.male_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
];
3 changes: 1 addition & 2 deletions src/locales/nb_NO/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.female_first_name}} {{person.female_first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.male_first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/pt_BR/person/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
5 changes: 1 addition & 4 deletions src/locales/pt_PT/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export default [
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
'{{person.male_prefix}} {{person.male_first_name}} {{person.last_name}}',
'{{person.female_prefix}} {{person.female_first_name}} {{person.last_name}}',
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
];
11 changes: 3 additions & 8 deletions src/locales/ro/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
export default [
'{{person.male_first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.male_first_name}}',
'{{person.prefix}} {{person.male_first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}, {{person.suffix}}',
'{{person.prefix}} {{person.male_first_name}} {{person.last_name}}, {{person.suffix}}',
'{{person.female_first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.female_first_name}}',
'{{person.prefix}} {{person.female_first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}}',
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
];
12 changes: 4 additions & 8 deletions src/locales/ru/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export default [
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.male_last_name}} {{person.male_first_name}}',
'{{person.male_first_name}} {{person.male_middle_name}} {{person.male_last_name}}',
'{{person.male_last_name}} {{person.male_first_name}} {{person.male_middle_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}}',
'{{person.female_first_name}} {{person.female_middle_name}} {{person.female_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}} {{person.female_middle_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}}',
'{{person.first_name}} {{person.middle_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}} {{person.middle_name}}',
];
9 changes: 3 additions & 6 deletions src/locales/sk/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export default [
'{{person.prefix}} {{person.male_first_name}} {{person.male_last_name}}',
'{{person.prefix}} {{person.female_first_name}} {{person.female_last_name}}',
'{{person.male_first_name}} {{person.male_last_name}} {{person.suffix}}',
'{{person.female_first_name}} {{person.female_last_name}} {{person.suffix}}',
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/sv/person/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ export default [
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
2 changes: 0 additions & 2 deletions src/locales/tr/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
];
12 changes: 4 additions & 8 deletions src/locales/uk/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export default [
'{{person.male_first_name}} {{person.male_last_name}}',
'{{person.male_last_name}} {{person.male_first_name}}',
'{{person.male_first_name}} {{person.male_middle_name}} {{person.male_last_name}}',
'{{person.male_last_name}} {{person.male_first_name}} {{person.male_middle_name}}',
'{{person.female_first_name}} {{person.female_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}}',
'{{person.female_first_name}} {{person.female_middle_name}} {{person.female_last_name}}',
'{{person.female_last_name}} {{person.female_first_name}} {{person.female_middle_name}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}}',
'{{person.first_name}} {{person.middle_name}} {{person.last_name}}',
'{{person.last_name}} {{person.first_name}} {{person.middle_name}}',
];
4 changes: 0 additions & 4 deletions src/locales/ur/person/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ export default [
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}} {{person.suffix}}',
'{{person.first_name}} {{person.last_name}}',
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
'{{person.male_first_name}} بن {{person.male_first_name}}',
'{{person.female_first_name}} بنت {{person.male_first_name}}',
];
6 changes: 1 addition & 5 deletions src/locales/vi/person/name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export default [
'{{person.male_first_name}} {{person.last_name}}',
'{{person.female_first_name}} {{person.last_name}}',
'{{person.first_name}} {{person.last_name}}',
];
export default ['{{person.first_name}} {{person.last_name}}'];
2 changes: 1 addition & 1 deletion src/locales/zh_CN/person/name.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default ['{{person.first_name}}{{person.last_name}}'];
export default ['{{person.last_name}}{{person.first_name}}'];
2 changes: 1 addition & 1 deletion src/locales/zh_TW/person/name.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default ['{{person.first_name}}{{person.last_name}}'];
export default ['{{person.last_name}}{{person.first_name}}'];
37 changes: 13 additions & 24 deletions src/modules/person/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,22 @@ export class PersonModule {
sex?: SexType;
} = {}
): string {
const {
sex = this.faker.helpers.arrayElement([Sex.Female, Sex.Male]),
firstName = this.firstName(sex),
lastName = this.lastName(sex),
} = options;
const sex =
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
options.sex || this.faker.helpers.arrayElement([Sex.Female, Sex.Male]);

const nameParts: string[] = [];
const prefix = this.faker.helpers.maybe(() => this.prefix(sex), {
probability: 0.125,
});

if (prefix) {
nameParts.push(prefix);
}

nameParts.push(firstName);
nameParts.push(lastName);
const fullNamePattern: string = this.faker.helpers.arrayElement(
this.faker.definitions.person.name
);

const suffix = this.faker.helpers.maybe(() => this.suffix(), {
probability: 0.125,
const fullName = this.faker.helpers.mustache(fullNamePattern, {
'person.gender': () => this.gender(),
'person.prefix': () => this.prefix(sex),
'person.first_name': () => options.firstName || this.firstName(sex),
'person.middle_name': () => this.middleName(sex),
'person.last_name': () => options.lastName || this.lastName(sex),
ST-DDT marked this conversation as resolved.
Show resolved Hide resolved
'person.suffix': () => this.suffix(),
});

if (suffix) {
nameParts.push(suffix);
}

return nameParts.join(' ');
return fullName;
}

/**
Expand Down
Loading