Properly output marital status for female users

This commit is contained in:
Celestora 2022-05-30 10:46:27 +03:00
parent decd223221
commit 5d11cdbe46
4 changed files with 32 additions and 12 deletions

View file

@ -285,6 +285,19 @@ class User extends RowModel
{ {
return $this->getRecord()->marital_status; return $this->getRecord()->marital_status;
} }
function getLocalizedMaritalStatus(): string
{
$status = $this->getMaritalStatus();
$string = "relationship_$status";
if($this->isFemale()) {
$res = tr($string . "_fem");
if($res != ("@" . $string . "_fem"))
return $res; # If fem version exists, return
}
return tr($string);
}
function getContactEmail(): ?string function getContactEmail(): ?string
{ {

View file

@ -94,16 +94,18 @@
</td> </td>
<td> <td>
<select name="marialstatus"> <select name="marialstatus">
<option value="0" {if $user->getMaritalStatus() == 0}selected{/if}>{_"relationship_0"}</option> <option n:foreach="range(0, 8) as $i" n:attr="selected: ($user->getMaritalStatus() == $i)" value="{$i}">
<option value="1" {if $user->getMaritalStatus() == 1}selected{/if}>{_"relationship_1"}</option> {if $user->isFemale()}
<option value="2" {if $user->getMaritalStatus() == 2}selected{/if}>{_"relationship_2"}</option> {var $str = "relationship_$i"}
<option value="3" {if $user->getMaritalStatus() == 3}selected{/if}>{_"relationship_3"}</option> {if tr($str . "_fem") == ("@$str" . "_fem")}
<option value="4" {if $user->getMaritalStatus() == 4}selected{/if}>{_"relationship_4"}</option> {_"$str"}
<option value="5" {if $user->getMaritalStatus() == 5}selected{/if}>{_"relationship_5"}</option> {else}
<option value="6" {if $user->getMaritalStatus() == 6}selected{/if}>{_"relationship_6"}</option> {tr($str . "_fem")}
<option value="7" {if $user->getMaritalStatus() == 7}selected{/if}>{_"relationship_7"}</option> {/if}
<option value="8" {if $user->getMaritalStatus() == 8}selected{/if}>{_"relationship_8"}</option> {else}
{_"relationship_$i"}
{/if}
</option>
</select> </select>
</td> </td>
</tr> </tr>

View file

@ -358,7 +358,7 @@
</tr> </tr>
<tr> <tr>
<td class="label"><span class="nobold">{_"relationship"}:</span></td> <td class="label"><span class="nobold">{_"relationship"}:</span></td>
<td class="data">{var $marialStatus = $user->getMaritalStatus()}{_"relationship_$marialStatus"}</td> <td class="data">{$user->getLocalizedMaritalStatus()}</td>
</tr> </tr>
<tr> <tr>
<td class="label"><span class="nobold">{_"registration_date"}: </span></td> <td class="label"><span class="nobold">{_"registration_date"}: </span></td>

View file

@ -99,10 +99,15 @@
"relationship_3" = "Помолвлен"; "relationship_3" = "Помолвлен";
"relationship_4" = "Женат"; "relationship_4" = "Женат";
"relationship_5" = "В гражданском браке"; "relationship_5" = "В гражданском браке";
"relationship_6" = "Влюблен"; "relationship_6" = "Влюблён";
"relationship_7" = "Всё сложно"; "relationship_7" = "Всё сложно";
"relationship_8" = "В активном поиске"; "relationship_8" = "В активном поиске";
"relationship_1_fem" = "Не замужем";
"relationship_3_fem" = "Помолвлена";
"relationship_4_fem" = "Замужем";
"relationship_6_fem" = "Влюблена";
"politViews" = "Полит. взгляды"; "politViews" = "Полит. взгляды";
"politViews_0" = "Не выбраны"; "politViews_0" = "Не выбраны";