Skip to content

Commit

Permalink
Consolidate pronouns
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandernanberg committed Dec 18, 2024
1 parent 17f6c4d commit ae210be
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 250 deletions.
28 changes: 7 additions & 21 deletions docs/pronouns.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@ const PRONOUN_USAGE = {
}
const GenderConst = {
NOT_A_PERSON: 0
FEMALE_SINGULAR: 1
MALE_SINGULAR: 2
FEMALE_SINGULAR_GUESS: 3
MALE_SINGULAR_GUESS: 4
MIXED_UNKNOWN: 5
NEUTER_SINGULAR: 6
UNKNOWN_SINGULAR: 7
FEMALE_PLURAL: 8
MALE_PLURAL: 9
NEUTER_PLURAL: 10
UNKNOWN_PLURAL: 11
NOT_A_PERSON = 0,
FEMALE = 1,
MALE = 2,
UNKNOWN_SINGULAR = 7,
UNKNOWN_PLURAL = 11,
}
```

Expand Down Expand Up @@ -96,14 +89,7 @@ _Note how `reflexive` and `object` have 4 types_
V Name Subject Possessive Reflexive Object
=============================================================
0 NOT_A_PERSON they their themself this
1 FEMALE_SINGULAR she her herself her
2 MALE_SINGULAR he his himself him
3 FEMALE_SINGULAR_GUESS she her herself her
4 MALE_SINGULAR_GUESS he his himself him
5 MIXED_UNKNOWN they their themselves them
6 NEUTER_SINGULAR they their themself them
1 FEMALE she her herself her
2 MALE he his himself him
7 UNKNOWN_SINGULAR they their themself them
8 FEMALE_PLURAL they their themselves them
9 MALE_PLURAL they their themselves them
10 NEUTER_PLURAL they their themselves them
11 UNKNOWN_PLURAL they their themselves them
10 changes: 5 additions & 5 deletions example/src/example/Example.react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,16 @@ export default function Example() {
<fbs desc="Gender Select label">Not a person</fbs>
</option>
<option value={GenderConst.UNKNOWN_PLURAL}>
<fbs desc="Gender Select label">Unknown (Plural)</fbs>
<fbs desc="Gender Select label">Unknown (plural)</fbs>
</option>
<option value={GenderConst.UNKNOWN_SINGULAR}>
<fbs desc="Gender Select label">Unknown (singular)</fbs>
</option>
<option value={GenderConst.MALE_SINGULAR}>
<fbs desc="Gender Select label">Male (singular)</fbs>
<option value={GenderConst.MALE}>
<fbs desc="Gender Select label">Male</fbs>
</option>
<option value={GenderConst.FEMALE_SINGULAR}>
<fbs desc="Gender Select label">Female (singular)</fbs>
<option value={GenderConst.FEMALE}>
<fbs desc="Gender Select label">Female</fbs>
</option>
</select>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ exports[`Example.react renders the example 1`] = `
<option
value="11"
>
Unknown (Plural)
Unknown (plural)
</option>
<option
value="7"
Expand All @@ -201,12 +201,12 @@ exports[`Example.react renders the example 1`] = `
<option
value="2"
>
Male (singular)
Male
</option>
<option
value="1"
>
Female (singular)
Female
</option>
</select>
</span>
Expand Down
165 changes: 17 additions & 148 deletions packages/babel-plugin-fbtee/src/Gender.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
type GenderConfig = {
is_female: boolean;
is_guess: boolean;
is_male: boolean;
is_mixed: boolean;
is_neuter: boolean;
is_plural: boolean;
is_unknown: boolean;
object: string;
Expand All @@ -15,41 +12,23 @@ type GenderConfig = {

export enum GenderConst {
NOT_A_PERSON = 0,
FEMALE_SINGULAR = 1,
MALE_SINGULAR = 2,
FEMALE_SINGULAR_GUESS = 3,
MALE_SINGULAR_GUESS = 4,
// 5 seems to indicate a group of people who may be of mixed gender
MIXED_UNKNOWN = 5,
NEUTER_SINGULAR = 6,
FEMALE = 1,
MALE = 2,
UNKNOWN_SINGULAR = 7,
FEMALE_PLURAL = 8,
MALE_PLURAL = 9,
NEUTER_PLURAL = 10,
UNKNOWN_PLURAL = 11,
}

export const Genders = [
GenderConst.NOT_A_PERSON,
GenderConst.FEMALE_SINGULAR,
GenderConst.MALE_SINGULAR,
GenderConst.FEMALE_SINGULAR_GUESS,
GenderConst.MALE_SINGULAR_GUESS,
GenderConst.MIXED_UNKNOWN,
GenderConst.NEUTER_SINGULAR,
GenderConst.UNKNOWN_SINGULAR,
GenderConst.FEMALE_PLURAL,
GenderConst.MALE_PLURAL,
GenderConst.NEUTER_PLURAL,
GenderConst.UNKNOWN_PLURAL,
GenderConst.FEMALE,
GenderConst.MALE,
] as const;

const NotAPerson = {
is_female: false,
is_guess: false,
is_male: false,
is_mixed: false,
is_neuter: false,
is_plural: false,
is_unknown: true,
object: 'this',
Expand All @@ -63,10 +42,7 @@ const data: Partial<Record<GenderConst, GenderConfig>> = {
[GenderConst.NOT_A_PERSON]: NotAPerson,
[GenderConst.UNKNOWN_SINGULAR]: {
is_female: false,
is_guess: false,
is_male: false,
is_mixed: false,
is_neuter: false,
is_plural: false,
is_unknown: true,
object: 'them',
Expand All @@ -75,146 +51,39 @@ const data: Partial<Record<GenderConst, GenderConfig>> = {
string: 'unknown singular',
subject: 'they',
},
[GenderConst.FEMALE_SINGULAR]: {
is_female: true,
is_guess: false,
[GenderConst.UNKNOWN_PLURAL]: {
is_female: false,
is_male: false,
is_mixed: false,
is_neuter: false,
is_plural: false,
is_unknown: false,
object: 'her',
possessive: 'her',
reflexive: 'herself',
string: 'female singular',
subject: 'she',
is_plural: true,
is_unknown: true,
object: 'them',
possessive: 'their',
reflexive: 'themselves',
string: 'unknown plural',
subject: 'they',
},
[GenderConst.FEMALE_SINGULAR_GUESS]: {
[GenderConst.FEMALE]: {
is_female: true,
is_guess: true,
is_male: false,
is_mixed: false,
is_neuter: false,
is_plural: false,
is_unknown: false,
object: 'her',
possessive: 'her',
reflexive: 'herself',
string: 'female singular',
string: 'female',
subject: 'she',
},
[GenderConst.MALE_SINGULAR]: {
[GenderConst.MALE]: {
is_female: false,
is_guess: false,
is_male: true,
is_mixed: false,
is_neuter: false,
is_plural: false,
is_unknown: false,
object: 'him',
possessive: 'his',
reflexive: 'himself',
string: 'male singular',
string: 'male',
subject: 'he',
},
[GenderConst.MALE_SINGULAR_GUESS]: {
is_female: false,
is_guess: true,
is_male: true,
is_mixed: false,
is_neuter: false,
is_plural: false,
is_unknown: false,
object: 'him',
possessive: 'his',
reflexive: 'himself',
string: 'male singular',
subject: 'he',
},
[GenderConst.NEUTER_SINGULAR]: {
is_female: false,
is_guess: false,
is_male: false,
is_mixed: false,
is_neuter: true,
is_plural: false,
is_unknown: false,
object: 'them',
possessive: 'their',
reflexive: 'themself',
string: 'neuter singular',
subject: 'they',
},
[GenderConst.MIXED_UNKNOWN]: {
is_female: false,
is_guess: false,
is_male: false,
is_mixed: true,
is_neuter: false,
is_plural: true,
is_unknown: false,
object: 'them',
possessive: 'their',
reflexive: 'themselves',
string: 'mixed plural',
subject: 'they',
},
[GenderConst.FEMALE_PLURAL]: {
is_female: true,
is_guess: false,
is_male: false,
is_mixed: false,
is_neuter: false,
is_plural: true,
is_unknown: false,
object: 'them',
possessive: 'their',
reflexive: 'themselves',
string: 'female plural',
subject: 'they',
},
[GenderConst.MALE_PLURAL]: {
is_female: false,
is_guess: false,
is_male: true,
is_mixed: false,
is_neuter: false,
is_plural: true,
is_unknown: false,
object: 'them',
possessive: 'their',
reflexive: 'themselves',
string: 'male plural',
subject: 'they',
},
[GenderConst.NEUTER_PLURAL]: {
is_female: false,
is_guess: false,
is_male: false,
is_mixed: false,
is_neuter: true,
is_plural: true,
is_unknown: false,
object: 'them',
possessive: 'their',
reflexive: 'themselves',
string: 'neuter plural',
subject: 'they',
},
[GenderConst.UNKNOWN_PLURAL]: {
is_female: false,
is_guess: false,
is_male: false,
is_mixed: false,
is_neuter: false,
is_plural: true,
is_unknown: true,
object: 'them',
possessive: 'their',
reflexive: 'themselves',
string: 'unknown plural',
subject: 'they',
},
} as const;

export function getData(
Expand Down
15 changes: 4 additions & 11 deletions packages/babel-plugin-fbtee/src/fbt-nodes/FbtPronounNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,15 @@ function getPronounGenderKey(
? GenderConst.NOT_A_PERSON
: GenderConst.UNKNOWN_PLURAL;

case GenderConst.FEMALE_SINGULAR:
case GenderConst.FEMALE_SINGULAR_GUESS:
return GenderConst.FEMALE_SINGULAR;
case GenderConst.FEMALE:
return GenderConst.FEMALE;

case GenderConst.MALE_SINGULAR:
case GenderConst.MALE_SINGULAR_GUESS:
return GenderConst.MALE_SINGULAR;
case GenderConst.MALE:
return GenderConst.MALE;

case GenderConst.MIXED_UNKNOWN:
case GenderConst.FEMALE_PLURAL:
case GenderConst.MALE_PLURAL:
case GenderConst.NEUTER_PLURAL:
case GenderConst.UNKNOWN_PLURAL:
return GenderConst.UNKNOWN_PLURAL;

case GenderConst.NEUTER_SINGULAR:
case GenderConst.UNKNOWN_SINGULAR:
return usage === ValidPronounUsagesKeys.reflexive
? GenderConst.NOT_A_PERSON
Expand Down
8 changes: 8 additions & 0 deletions packages/fbtee/ReactTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ enum IntlVariations {
GENDER_UNKNOWN = 3,
}

enum GenderConst {
NOT_A_PERSON = 0,
FEMALE = 1,
MALE = 2,
UNKNOWN_SINGULAR = 7,
UNKNOWN_PLURAL = 11,
}

export type ParamOptions = {
/**
* `IntlVariations.GENDER_*` Pass the gender of the parameter for correctly variated text.
Expand Down
11 changes: 2 additions & 9 deletions packages/fbtee/src/GenderConst.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
enum GenderConst {
NOT_A_PERSON = 0,
FEMALE_SINGULAR = 1,
MALE_SINGULAR = 2,
FEMALE_SINGULAR_GUESS = 3,
MALE_SINGULAR_GUESS = 4,
MIXED_UNKNOWN = 5,
NEUTER_SINGULAR = 6,
FEMALE = 1,
MALE = 2,
UNKNOWN_SINGULAR = 7,
FEMALE_PLURAL = 8,
MALE_PLURAL = 9,
NEUTER_PLURAL = 10,
UNKNOWN_PLURAL = 11,
}

Expand Down
Loading

0 comments on commit ae210be

Please sign in to comment.