faker
faker copied to clipboard
Clean up `generic` prefixes
`generic` is intended for cases that don't represent male or female specifically.
In this case it looks like it is just the union of male and female, so it can now be omitted, because it will fallback to the gendered version automatically if it cannot find generic ones.
Originally posted by @ST-DDT in https://github.com/faker-js/faker/pull/3020#discussion_r1719049653
Note this should be cleaned up in other locales e.g. https://github.com/faker-js/faker/blob/next/src/locales/en/person/prefix.ts where generic is just the union of male and female.
Currently en has:
export default {
generic: ['Dr.', 'Miss', 'Mr.', 'Mrs.', 'Ms.'],
female: ['Mrs.', 'Ms.', 'Miss', 'Dr.'],
male: ['Mr.', 'Dr.'],
};
which should be
export default {
female: ['Mrs.', 'Ms.', 'Miss', 'Dr.'],
male: ['Mr.', 'Dr.'],
};
although i'd argue it would be more sensibly written as
export default {
generic: ['Dr.'],
female: ['Mrs.', 'Ms.', 'Miss'],
male: ['Mr.'],
};
However that won't work currently (as generic takes priority, so everyone would be Dr). Perhaps selectDefinition should return randomly from the generic plus female/male lists when sex is undefined?
Team Decision
- We decided to split the definitions by applicability.
- See this PR for details: #3259
- #3259