faker icon indicating copy to clipboard operation
faker copied to clipboard

Clean up `generic` prefixes

Open matthewmayer opened this issue 1 year ago • 3 comments

          `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 avatar Aug 15 '24 22:08 matthewmayer

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 avatar Aug 15 '24 22:08 matthewmayer

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?

matthewmayer avatar Aug 15 '24 23:08 matthewmayer

Team Decision

  • We decided to split the definitions by applicability.
  • See this PR for details: #3259
    • #3259

ST-DDT avatar Nov 12 '24 21:11 ST-DDT