summaryrefslogtreecommitdiff
path: root/app/SurnameTradition.php
blob: 18d3b60a7bb3f52539ec34466dd7bbdf0cec4055 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php

/**
 * webtrees: online genealogy
 * Copyright (C) 2021 webtrees development team
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

declare(strict_types=1);

namespace Fisharebest\Webtrees;

use Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition;
use Fisharebest\Webtrees\SurnameTradition\SurnameTraditionInterface;

/**
 *
 */
class SurnameTradition
{
    /**
     * Create a surname tradition object for a given surname tradition name.
     *
     * @param string $name Internal name of the surname tradition
     *
     * @return SurnameTraditionInterface
     */
    public static function create(string $name): SurnameTraditionInterface
    {
        switch ($name) {
            case 'paternal':
                return new PaternalSurnameTradition();
            case 'patrilineal':
                return new PatrilinealSurnameTradition();
            case 'matrilineal':
                return new MatrilinealSurnameTradition();
            case 'portuguese':
                return new PortugueseSurnameTradition();
            case 'spanish':
                return new SpanishSurnameTradition();
            case 'polish':
                return new PolishSurnameTradition();
            case 'lithuanian':
                return new LithuanianSurnameTradition();
            case 'icelandic':
                return new IcelandicSurnameTradition();
            default:
                return new DefaultSurnameTradition();
        }
    }

    /**
     * A list of known surname traditions, with their descriptions
     *
     * @return array<string>
     */
    public static function allDescriptions(): array
    {
        return [
            'paternal'    => I18N::translateContext('Surname tradition', 'paternal') . ' — ' .
                /* I18N: In the paternal surname tradition, ... */
                I18N::translate('Children take their father’s surname.') . ' ' .
                /* I18N: In the paternal surname tradition, ... */
                I18N::translate('Wives take their husband’s surname.'),
            'patrilineal' =>
                /* I18N: A system where children take their father’s surname */
                I18N::translate('patrilineal') . ' — ' .
                /* I18N: In the patrilineal surname tradition, ... */
                I18N::translate('Children take their father’s surname.'),
            'matrilineal' => /* I18N: A system where children take their mother’s surname */
                I18N::translate('matrilineal') . ' — ' .
                /* I18N: In the matrilineal surname tradition, ... */
                I18N::translate('Children take their mother’s surname.'),
            'spanish'     => I18N::translateContext('Surname tradition', 'Spanish') . ' — ' .
                /* I18N: In the Spanish surname tradition, ... */
                I18N::translate('Children take one surname from the father and one surname from the mother.'),
            'portuguese'  => I18N::translateContext('Surname tradition', 'Portuguese') . ' — ' .
                /* I18N: In the Portuguese surname tradition, ... */
                I18N::translate('Children take one surname from the mother and one surname from the father.'),
            'icelandic'   => I18N::translateContext('Surname tradition', 'Icelandic') . ' — ' .
                /* I18N: In the Icelandic surname tradition, ... */
                I18N::translate('Children take a patronym instead of a surname.'),
            'polish'      => I18N::translateContext('Surname tradition', 'Polish') . ' — ' .
                /* I18N: In the Polish surname tradition, ... */
                I18N::translate('Children take their father’s surname.') . ' ' .
                /* I18N: In the Polish surname tradition, ... */
                I18N::translate('Wives take their husband’s surname.') . ' ' .
                /* I18N: In the Polish surname tradition, ... */
                I18N::translate('Surnames are inflected to indicate an individual’s gender.'),
            'lithuanian'  => I18N::translateContext('Surname tradition', 'Lithuanian') . ' — ' .
                /* I18N: In the Lithuanian surname tradition, ... */
                I18N::translate('Children take their father’s surname.') . ' ' .
                /* I18N: In the Lithuanian surname tradition, ... */
                I18N::translate('Wives take their husband’s surname.') . ' ' .
                /* I18N: In the Lithuanian surname tradition, ... */
                I18N::translate('Surnames are inflected to indicate an individual’s gender and marital status.'),
            'none'        => I18N::translateContext('Surname tradition', 'none'),
        ];
    }
}