Skip to content

Commit

Permalink
feat: check male translation and fall back to generic (#6039)
Browse files Browse the repository at this point in the history
  • Loading branch information
codemonkeysoftware authored May 6, 2022
1 parent 1a00864 commit 4ba9062
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/Models/Relationship/RelationshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,16 @@ public function getLocalizedName(Contact $contact = null, bool $includeOpposite
}

$femaleVersion = trans('app.relationship_type_'.$this->name.'_female');
$maleVersion = trans('app.relationship_type_'.$this->name);
$maleVersion = trans('app.relationship_type_'.$this->name.'_male');
if ($maleVersion === 'app.relationship_type_'.$this->name.'_male') {
$maleVersion = trans('app.relationship_type_'.$this->name);
}

if (! is_null($contact)) {
$maleVersionWithName = trans('app.relationship_type_'.$this->name.'_with_name', ['name' => $contact->name]);
$maleVersionWithName = trans('app.relationship_type_'.$this->name.'_male_with_name', ['name' => $contact->name]);
if ($maleVersionWithName === 'app.relationship_type_'.$this->name.'_male_with_name') {
$maleVersionWithName = trans('app.relationship_type_'.$this->name.'_with_name');
}
$femaleVersionWithName = trans('app.relationship_type_'.$this->name.'_female_with_name', ['name' => $contact->name]);

// include the reverse of the relation in the string (masculine/feminine)
Expand Down
30 changes: 30 additions & 0 deletions resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@

'relationship_type_partner' => 'significant other',
'relationship_type_partner_female' => 'significant other',
'relationship_type_partner_male' => 'significant other',
'relationship_type_partner_with_name' => ':name’s significant other',
'relationship_type_partner_female_with_name' => ':name’s significant other',
'relationship_type_partner_male_with_name' => ':name’s significant other',

'relationship_type_spouse' => 'spouse',
'relationship_type_spouse_female' => 'wife',
Expand All @@ -152,23 +154,31 @@

'relationship_type_date' => 'date',
'relationship_type_date_female' => 'date',
'relationship_type_date_male' => 'date',
'relationship_type_date_with_name' => ':name’s date',
'relationship_type_date_female_with_name' => ':name’s date',
'relationship_type_date_male_with_name' => ':name’s date',

'relationship_type_lover' => 'lover',
'relationship_type_lover_female' => 'lover',
'relationship_type_lover_male' => 'lover',
'relationship_type_lover_with_name' => ':name’s lover',
'relationship_type_lover_female_with_name' => ':name’s lover',
'relationship_type_lover_male_with_name' => ':name’s lover',

'relationship_type_inlovewith' => 'in love with',
'relationship_type_inlovewith_female' => 'in love with',
'relationship_type_inlovewith_male' => 'in love with',
'relationship_type_inlovewith_with_name' => 'someone :name is in love with',
'relationship_type_inlovewith_female_with_name' => 'someone :name is in love with',
'relationship_type_inlovewith_male_with_name' => 'someone :name is in love with',

'relationship_type_lovedby' => 'loved by',
'relationship_type_lovedby_female' => 'loved by',
'relationship_type_lovedby_male' => 'loved by',
'relationship_type_lovedby_with_name' => ':name’s secret lover',
'relationship_type_lovedby_female_with_name' => ':name’s secret lover',
'relationship_type_lovedby_male_with_name' => ':name’s secret lover',

'relationship_type_ex' => 'ex-partner',
'relationship_type_ex_female' => 'ex-girlfriend',
Expand Down Expand Up @@ -228,18 +238,24 @@

'relationship_type_uncle' => 'uncle',
'relationship_type_uncle_female' => 'aunt',
'relationship_type_uncle_male' => 'uncle',
'relationship_type_uncle_with_name' => ':name’s uncle',
'relationship_type_uncle_female_with_name' => ':name’s aunt',
'relationship_type_uncle_male_with_name' => ':name’s uncle',

'relationship_type_nephew' => 'nephew',
'relationship_type_nephew_female' => 'niece',
'relationship_type_nephew_male' => 'nephew',
'relationship_type_nephew_with_name' => ':name’s nephew',
'relationship_type_nephew_female_with_name' => ':name’s niece',
'relationship_type_nephew_male_with_name' => ':name’s nephew',

'relationship_type_cousin' => 'cousin',
'relationship_type_cousin_female' => 'cousin',
'relationship_type_cousin_male' => 'cousin',
'relationship_type_cousin_with_name' => ':name’s cousin',
'relationship_type_cousin_female_with_name' => ':name’s cousin',
'relationship_type_cousin_male_with_name' => ':name’s cousin',

'relationship_type_godfather' => 'godparent',
'relationship_type_godfather_female' => 'godmother',
Expand All @@ -257,38 +273,52 @@

'relationship_type_friend' => 'friend',
'relationship_type_friend_female' => 'friend',
'relationship_type_friend_male' => 'friend',
'relationship_type_friend_with_name' => ':name’s friend',
'relationship_type_friend_female_with_name' => ':name’s friend',
'relationship_type_friend_male_with_name' => ':name’s friend',

'relationship_type_bestfriend' => 'best friend',
'relationship_type_bestfriend_female' => 'best friend',
'relationship_type_bestfriend_male' => 'best friend',
'relationship_type_bestfriend_with_name' => ':name’s best friend',
'relationship_type_bestfriend_female_with_name' => ':name’s best friend',
'relationship_type_bestfriend_male_with_name' => ':name’s best friend',

'relationship_type_colleague' => 'colleague',
'relationship_type_colleague_female' => 'colleague',
'relationship_type_colleague_male' => 'colleague',
'relationship_type_colleague_with_name' => ':name’s colleague',
'relationship_type_colleague_female_with_name' => ':name’s colleague',
'relationship_type_colleague_male_with_name' => ':name’s colleague',

'relationship_type_boss' => 'boss',
'relationship_type_boss_female' => 'boss',
'relationship_type_boss_male' => 'boss',
'relationship_type_boss_with_name' => ':name’s boss',
'relationship_type_boss_female_with_name' => ':name’s boss',
'relationship_type_boss_male_with_name' => ':name’s boss',

'relationship_type_subordinate' => 'subordinate',
'relationship_type_subordinate_female' => 'subordinate',
'relationship_type_subordinate_male' => 'subordinate',
'relationship_type_subordinate_with_name' => ':name’s subordinate',
'relationship_type_subordinate_female_with_name' => ':name’s subordinate',
'relationship_type_subordinate_male_with_name' => ':name’s subordinate',

'relationship_type_mentor' => 'mentor',
'relationship_type_mentor_female' => 'mentor',
'relationship_type_mentor_male' => 'mentor',
'relationship_type_mentor_with_name' => ':name’s mentor',
'relationship_type_mentor_female_with_name' => ':name’s mentor',
'relationship_type_mentor_male_with_name' => ':name’s mentor',

'relationship_type_protege' => 'protégé',
'relationship_type_protege_female' => 'protégé',
'relationship_type_protege_male' => 'protégé',
'relationship_type_protege_with_name' => ':name’s protégé',
'relationship_type_protege_female_with_name' => ':name’s protégé',
'relationship_type_protege_male_with_name' => ':name’s protégé',

'relationship_type_ex_husband' => 'ex-spouse',
'relationship_type_ex_husband_female' => 'ex-wife',
Expand Down

0 comments on commit 4ba9062

Please sign in to comment.