From ae210beb6675815e74c7fee728ebb55f8d02bafd Mon Sep 17 00:00:00 2001 From: Alexander Nanberg Date: Sat, 14 Dec 2024 10:20:28 +0100 Subject: [PATCH] Consolidate pronouns --- docs/pronouns.md | 28 +-- example/src/example/Example.react.tsx | 10 +- .../__snapshots__/Example.react-test.tsx.snap | 6 +- packages/babel-plugin-fbtee/src/Gender.tsx | 165 ++---------------- .../src/fbt-nodes/FbtPronounNode.tsx | 15 +- packages/fbtee/ReactTypes.d.ts | 8 + packages/fbtee/src/GenderConst.tsx | 11 +- packages/fbtee/src/IntlGender.tsx | 9 +- .../__tests__/__snapshots__/fbt-test.tsx.snap | 48 ++--- packages/fbtee/src/__tests__/fbt-test.tsx | 17 +- packages/fbtee/src/fbt.tsx | 15 +- 11 files changed, 82 insertions(+), 250 deletions(-) diff --git a/docs/pronouns.md b/docs/pronouns.md index 5be90ca1..950158d0 100644 --- a/docs/pronouns.md +++ b/docs/pronouns.md @@ -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, } ``` @@ -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 diff --git a/example/src/example/Example.react.tsx b/example/src/example/Example.react.tsx index caa4831c..66e24413 100644 --- a/example/src/example/Example.react.tsx +++ b/example/src/example/Example.react.tsx @@ -249,16 +249,16 @@ export default function Example() { Not a person - - diff --git a/example/src/example/__tests__/__snapshots__/Example.react-test.tsx.snap b/example/src/example/__tests__/__snapshots__/Example.react-test.tsx.snap index a4fc02f7..f26bf6a5 100755 --- a/example/src/example/__tests__/__snapshots__/Example.react-test.tsx.snap +++ b/example/src/example/__tests__/__snapshots__/Example.react-test.tsx.snap @@ -191,7 +191,7 @@ exports[`Example.react renders the example 1`] = ` diff --git a/packages/babel-plugin-fbtee/src/Gender.tsx b/packages/babel-plugin-fbtee/src/Gender.tsx index c7515e8a..fd19ccf3 100644 --- a/packages/babel-plugin-fbtee/src/Gender.tsx +++ b/packages/babel-plugin-fbtee/src/Gender.tsx @@ -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; @@ -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', @@ -63,10 +42,7 @@ const data: Partial> = { [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', @@ -75,146 +51,39 @@ const data: Partial> = { 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( diff --git a/packages/babel-plugin-fbtee/src/fbt-nodes/FbtPronounNode.tsx b/packages/babel-plugin-fbtee/src/fbt-nodes/FbtPronounNode.tsx index c9e081d5..37d5a76d 100644 --- a/packages/babel-plugin-fbtee/src/fbt-nodes/FbtPronounNode.tsx +++ b/packages/babel-plugin-fbtee/src/fbt-nodes/FbtPronounNode.tsx @@ -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 diff --git a/packages/fbtee/ReactTypes.d.ts b/packages/fbtee/ReactTypes.d.ts index ea7d2ed5..9fb580d9 100644 --- a/packages/fbtee/ReactTypes.d.ts +++ b/packages/fbtee/ReactTypes.d.ts @@ -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. diff --git a/packages/fbtee/src/GenderConst.tsx b/packages/fbtee/src/GenderConst.tsx index bca17cc8..2fe6a0a7 100644 --- a/packages/fbtee/src/GenderConst.tsx +++ b/packages/fbtee/src/GenderConst.tsx @@ -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, } diff --git a/packages/fbtee/src/IntlGender.tsx b/packages/fbtee/src/IntlGender.tsx index 6874681a..dd011891 100644 --- a/packages/fbtee/src/IntlGender.tsx +++ b/packages/fbtee/src/IntlGender.tsx @@ -1,12 +1,11 @@ import invariant from 'invariant'; import GenderConst from './GenderConst.tsx'; -type DisplayGenderConstType = 'UNKNOWN' | 'FEMALE' | 'MALE' | 'NEUTER'; +type DisplayGenderConstType = 'UNKNOWN' | 'FEMALE' | 'MALE'; const DisplayGenderConst = { FEMALE: 'FEMALE', MALE: 'MALE', - NEUTER: 'NEUTER', UNKNOWN: 'UNKNOWN', } as const; @@ -26,11 +25,9 @@ export function fromMultiple(genders: Array): number { export function fromDisplayGender(gender: DisplayGenderConstType): number { switch (gender) { case DisplayGenderConst.MALE: - return GenderConst.MALE_SINGULAR; + return GenderConst.MALE; case DisplayGenderConst.FEMALE: - return GenderConst.FEMALE_SINGULAR; - case DisplayGenderConst.NEUTER: - return GenderConst.NEUTER_SINGULAR; + return GenderConst.FEMALE; default: return GenderConst.NOT_A_PERSON; } diff --git a/packages/fbtee/src/__tests__/__snapshots__/fbt-test.tsx.snap b/packages/fbtee/src/__tests__/__snapshots__/fbt-test.tsx.snap index cd4b963d..24f5895c 100644 --- a/packages/fbtee/src/__tests__/__snapshots__/fbt-test.tsx.snap +++ b/packages/fbtee/src/__tests__/__snapshots__/fbt-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE_SINGULAR, object=comment, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE, object=comment, count=1 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -19,7 +19,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE_SINGULAR, object=comment, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE, object=comment, count=10 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -38,7 +38,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE_SINGULAR, object=photo, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE, object=photo, count=1 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -57,7 +57,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE_SINGULAR, object=photo, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=FEMALE, object=photo, count=10 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -76,7 +76,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE_SINGULAR, object=comment, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE, object=comment, count=1 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -95,7 +95,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE_SINGULAR, object=comment, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE, object=comment, count=10 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -114,7 +114,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE_SINGULAR, object=photo, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE, object=photo, count=1 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -133,7 +133,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE_SINGULAR, object=photo, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Betty, ownerGender=MALE, object=photo, count=10 should produce proper nested fbt results 1`] = ` [ "Betty clicked on ", @@ -228,7 +228,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Betty, owner ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE_SINGULAR, object=comment, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE, object=comment, count=1 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -247,7 +247,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE_SINGULAR, object=comment, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE, object=comment, count=10 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -266,7 +266,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE_SINGULAR, object=photo, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE, object=photo, count=1 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -285,7 +285,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE_SINGULAR, object=photo, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=FEMALE, object=photo, count=10 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -304,7 +304,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE_SINGULAR, object=comment, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE, object=comment, count=1 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -323,7 +323,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE_SINGULAR, object=comment, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE, object=comment, count=10 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -342,7 +342,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE_SINGULAR, object=photo, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE, object=photo, count=1 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -361,7 +361,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE_SINGULAR, object=photo, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGender=MALE, object=photo, count=10 should produce proper nested fbt results 1`] = ` [ "Bob clicked on ", @@ -456,7 +456,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Bob, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE_SINGULAR, object=comment, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE, object=comment, count=1 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -475,7 +475,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE_SINGULAR, object=comment, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE, object=comment, count=10 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -494,7 +494,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE_SINGULAR, object=photo, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE, object=photo, count=1 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -513,7 +513,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE_SINGULAR, object=photo, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=FEMALE, object=photo, count=10 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -532,7 +532,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE_SINGULAR, object=comment, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE, object=comment, count=1 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -551,7 +551,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE_SINGULAR, object=comment, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE, object=comment, count=10 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -570,7 +570,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE_SINGULAR, object=photo, count=1 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE, object=photo, count=1 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", @@ -589,7 +589,7 @@ exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGe ] `; -exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE_SINGULAR, object=photo, count=10 +exports[`fbt : given a string with implicit parameters where viewer=Kim, ownerGender=MALE, object=photo, count=10 should produce proper nested fbt results 1`] = ` [ "Kim clicked on ", diff --git a/packages/fbtee/src/__tests__/fbt-test.tsx b/packages/fbtee/src/__tests__/fbt-test.tsx index 1f4dadcd..cdab2fda 100644 --- a/packages/fbtee/src/__tests__/fbt-test.tsx +++ b/packages/fbtee/src/__tests__/fbt-test.tsx @@ -254,8 +254,8 @@ describe('fbt', () => { }); it('should create a tuple for fbt.subject if valid', () => { - expect(fbtInternal._subject(GenderConst.MALE_SINGULAR)).toEqual([ - [GenderConst.MALE_SINGULAR, '*'], + expect(fbtInternal._subject(GenderConst.MALE)).toEqual([ + [GenderConst.MALE, '*'], null, ]); expect(() => fbtInternal._subject(0)).toThrow('Invalid gender provided'); @@ -318,15 +318,8 @@ describe('fbt', () => { count: number; object: string; ownerGender: - | 'FEMALE_PLURAL' - | 'FEMALE_SINGULAR' - | 'FEMALE_SINGULAR_GUESS' - | 'MALE_PLURAL' - | 'MALE_SINGULAR' - | 'MALE_SINGULAR_GUESS' - | 'MIXED_UNKNOWN' - | 'NEUTER_PLURAL' - | 'NEUTER_SINGULAR' + | 'FEMALE' + | 'MALE' | 'NOT_A_PERSON' | 'UNKNOWN_PLURAL' | 'UNKNOWN_SINGULAR'; @@ -376,7 +369,7 @@ describe('fbt', () => { } = { counts: [1, 10], objects: ['photo', 'comment'], - ownerGenders: ['FEMALE_SINGULAR', 'MALE_SINGULAR', 'UNKNOWN_PLURAL'], + ownerGenders: ['FEMALE', 'MALE', 'UNKNOWN_PLURAL'], viewers: [ { gender: IntlVariations.GENDER_MALE, diff --git a/packages/fbtee/src/fbt.tsx b/packages/fbtee/src/fbt.tsx index 200457d7..89e52767 100644 --- a/packages/fbtee/src/fbt.tsx +++ b/packages/fbtee/src/fbt.tsx @@ -54,22 +54,15 @@ const 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 === ValidPronounUsages.reflexive ? GenderConst.NOT_A_PERSON