xref: /webtrees/app/Elements/RelationIsDescriptor.php (revision 4a9a60957058ca2a34e30a0d6f783e1540606590)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2022 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Elements;
21
22use Fisharebest\Webtrees\I18N;
23
24use function uasort;
25
26/**
27 * RELATION_IS_DESCRIPTOR := {Size=1:25}
28 * A word or phrase that states object 1's relation is object 2. For example
29 * you would read the following as "Joe Jacob's great grandson is the submitter
30 * pointed to by the @XREF:SUBM@":
31 * 0 INDI
32 * 1 NAME Joe /Jacob/
33 * 1 ASSO @<XREF:SUBM>@
34 * 2 RELA great grandson
35 */
36class RelationIsDescriptor extends AbstractElement
37{
38    protected const MAXIMUM_LENGTH = 25;
39
40    /**
41     * A list of controlled values for this element
42     *
43     * @param string $sex - the text depends on the sex of the *linked* individual
44     *
45     * @return array<int|string,string>
46     */
47    public function values(string $sex = 'U'): array
48    {
49        $values = [
50            'M' => [
51                ''                 => '',
52                'attendant'        => I18N::translateContext('MALE', 'Attendant'),
53                'attending'        => I18N::translateContext('MALE', 'Attending'),
54                'buyer'            => I18N::translateContext('MALE', 'Buyer'),
55                'civil_registrar'  => I18N::translateContext('MALE', 'Civil registrar'),
56                'employee'         => I18N::translateContext('MALE', 'Employee'),
57                'employer'         => I18N::translateContext('MALE', 'Employer'),
58                'friend'           => I18N::translateContext('MALE', 'Friend'),
59                'godparent'        => I18N::translate('Godfather'),
60                'godchild'         => I18N::translate('Godson'),
61                'guardian'         => I18N::translateContext('MALE', 'Guardian'),
62                'informant'        => I18N::translateContext('MALE', 'Informant'),
63                'lodger'           => I18N::translateContext('MALE', 'Lodger'),
64                'nurse'            => I18N::translateContext('MALE', 'Nurse'),
65                'owner'            => I18N::translateContext('MALE', 'Owner'),
66                'registry_officer' => I18N::translateContext('MALE', 'Registry officer'),
67                'seller'           => I18N::translateContext('MALE', 'Seller'),
68                'servant'          => I18N::translateContext('MALE', 'Servant'),
69                'slave'            => I18N::translateContext('MALE', 'Slave'),
70                'ward'             => I18N::translateContext('MALE', 'Ward'),
71            ],
72            'F' => [
73                'attendant'        => I18N::translateContext('FEMALE', 'Attendant'),
74                'attending'        => I18N::translateContext('FEMALE', 'Attending'),
75                'buyer'            => I18N::translateContext('FEMALE', 'Buyer'),
76                'civil_registrar'  => I18N::translateContext('FEMALE', 'Civil registrar'),
77                'employee'         => I18N::translateContext('FEMALE', 'Employee'),
78                'employer'         => I18N::translateContext('FEMALE', 'Employer'),
79                'friend'           => I18N::translateContext('FEMALE', 'Friend'),
80                'godparent'        => I18N::translate('Godmother'),
81                'godchild'         => I18N::translate('Goddaughter'),
82                'guardian'         => I18N::translateContext('FEMALE', 'Guardian'),
83                'informant'        => I18N::translateContext('FEMALE', 'Informant'),
84                'lodger'           => I18N::translateContext('FEMALE', 'Lodger'),
85                'nurse'            => I18N::translateContext('FEMALE', 'Nurse'),
86                'owner'            => I18N::translateContext('FEMALE', 'Owner'),
87                'registry_officer' => I18N::translateContext('FEMALE', 'Registry officer'),
88                'seller'           => I18N::translateContext('FEMALE', 'Seller'),
89                'servant'          => I18N::translateContext('FEMALE', 'Servant'),
90                'slave'            => I18N::translateContext('FEMALE', 'Slave'),
91                'ward'             => I18N::translateContext('FEMALE', 'Ward'),
92            ],
93            'U' => [
94                'attendant'        => I18N::translate('Attendant'),
95                'attending'        => I18N::translate('Attending'),
96                'best_man'         => I18N::translate('Best man'),
97                'bridesmaid'       => I18N::translate('Bridesmaid'),
98                'buyer'            => I18N::translate('Buyer'),
99                'circumciser'      => I18N::translate('Circumciser'),
100                'civil_registrar'  => I18N::translate('Civil registrar'),
101                'employee'         => I18N::translate('Employee'),
102                'employer'         => I18N::translate('Employer'),
103                'foster_child'     => I18N::translate('Foster child'),
104                'foster_father'    => I18N::translate('Foster father'),
105                'foster_mother'    => I18N::translate('Foster mother'),
106                'friend'           => I18N::translate('Friend'),
107                'godfather'        => I18N::translate('Godfather'),
108                'godmother'        => I18N::translate('Godmother'),
109                'godparent'        => I18N::translate('Godparent'),
110                'godson'           => I18N::translate('Godson'),
111                'goddaughter'      => I18N::translate('Goddaughter'),
112                'godchild'         => I18N::translate('Godchild'),
113                'guardian'         => I18N::translate('Guardian'),
114                'informant'        => I18N::translate('Informant'),
115                'lodger'           => I18N::translate('Lodger'),
116                'multiple'         => /* I18N: twin, triplet, etc. */ I18N::translate('Multiple birth'),
117                'nanny'            => I18N::translate('Nanny'),
118                'nurse'            => I18N::translate('Nurse'),
119                'owner'            => I18N::translate('Owner'),
120                'proxy'            => /* I18N: An individual that represents another */ I18N::translate('Proxy'),
121                'priest'           => I18N::translate('Priest'),
122                'rabbi'            => I18N::translate('Rabbi'),
123                'registry_officer' => I18N::translate('Registry officer'),
124                'seller'           => I18N::translate('Seller'),
125                'servant'          => I18N::translate('Servant'),
126                'slave'            => I18N::translate('Slave'),
127                'ward'             => I18N::translate('Ward'),
128                'witness'          => I18N::translate('Witness'),
129            ],
130        ];
131
132        $tmp = $values[$sex] ?? $values['U'];
133
134        uasort($tmp, I18N::comparator());
135
136        return $tmp;
137    }
138}
139