faker-js / faker

Generate massive amounts of fake data in the browser and node.js
https://fakerjs.dev
Other
12.46k stars 897 forks source link

Clean up `generic` prefixes #3058

Open matthewmayer opened 4 weeks ago

matthewmayer commented 4 weeks ago
          `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_

matthewmayer commented 4 weeks ago

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.

matthewmayer commented 4 weeks ago

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?