xref: /webtrees/app/Elements/LanguageId.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1c2ed51d1SGreg Roach<?php
2c2ed51d1SGreg Roach
3c2ed51d1SGreg Roach/**
4c2ed51d1SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6c2ed51d1SGreg Roach * This program is free software: you can redistribute it and/or modify
7c2ed51d1SGreg Roach * it under the terms of the GNU General Public License as published by
8c2ed51d1SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9c2ed51d1SGreg Roach * (at your option) any later version.
10c2ed51d1SGreg Roach * This program is distributed in the hope that it will be useful,
11c2ed51d1SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12c2ed51d1SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13c2ed51d1SGreg Roach * GNU General Public License for more details.
14c2ed51d1SGreg Roach * You should have received a copy of the GNU General Public License
15c2ed51d1SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16c2ed51d1SGreg Roach */
17c2ed51d1SGreg Roach
18c2ed51d1SGreg Roachdeclare(strict_types=1);
19c2ed51d1SGreg Roach
20c2ed51d1SGreg Roachnamespace Fisharebest\Webtrees\Elements;
21c2ed51d1SGreg Roach
22c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleAf;
23c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleAm;
24c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleAng;
25c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleAr;
26c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleAs;
27c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleBe;
28c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleBg;
29c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleBn;
30c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleBo;
31c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleCa;
32c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleCaEsValencia;
33c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleCs;
34c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleCu;
35c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleDa;
36c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleDe;
37c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleEl;
38c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleEn;
39c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleEo;
40c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleEs;
41c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleEt;
42c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleFa;
43c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleFi;
44c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleFo;
45c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleFr;
46c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleGu;
47c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleHaw;
48c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleHe;
49c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleHi;
50c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleHu;
51c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleHy;
52c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleId;
53c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleIs;
54c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleIt;
55c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleJa;
56c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleKa;
57c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleKm;
58c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleKn;
59c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleKo;
60c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleKok;
61c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleLo;
62c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleLt;
63c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleLv;
64c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleMk;
65c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleMl;
66c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleMr;
67c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleMy;
68c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleNe;
69c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleNl;
70c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleNn;
71c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleOr;
72c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocalePa;
73c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocalePl;
74c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocalePs;
75c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocalePt;
76c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleRo;
77c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleRu;
78c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleSk;
79c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleSl;
80c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleSq;
81c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleSr;
82c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleSv;
83c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleTa;
84c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleTe;
85c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleTh;
86c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleTl;
87c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleTr;
88c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleUk;
89c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleUr;
90c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleVi;
91c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleYi;
92c2ed51d1SGreg Roachuse Fisharebest\Localization\Locale\LocaleYue;
93e7e5b015SGreg Roachuse Fisharebest\Webtrees\I18N;
94e7e5b015SGreg Roach
953f810b5bSGreg Roachuse function strtoupper;
96c2ed51d1SGreg Roach
97c2ed51d1SGreg Roach/**
98c2ed51d1SGreg Roach * LANGUAGE_ID := {Size=1:15}
99c2ed51d1SGreg Roach * The human language in which the data in the transmission is normally read or
100c2ed51d1SGreg Roach * written. It is used primarily by programs to select language-specific
101c2ed51d1SGreg Roach * sorting sequences and phonetic name matching algorithms.
102c2ed51d1SGreg Roach */
103c2ed51d1SGreg Roachclass LanguageId extends AbstractElement
104c2ed51d1SGreg Roach{
105c2ed51d1SGreg Roach    /**
106c2ed51d1SGreg Roach     * Convert a value to a canonical form.
107c2ed51d1SGreg Roach     *
108c2ed51d1SGreg Roach     * @param string $value
109c2ed51d1SGreg Roach     *
110c2ed51d1SGreg Roach     * @return string
111c2ed51d1SGreg Roach     */
112c2ed51d1SGreg Roach    public function canonical(string $value): string
113c2ed51d1SGreg Roach    {
1143f810b5bSGreg Roach        return strtoupper(parent::canonical($value));
115c2ed51d1SGreg Roach    }
116c2ed51d1SGreg Roach
117c2ed51d1SGreg Roach    /**
118c2ed51d1SGreg Roach     * A list of controlled values for this element
119c2ed51d1SGreg Roach     *
120c2ed51d1SGreg Roach     * @return array<int|string,string>
121c2ed51d1SGreg Roach     */
122c2ed51d1SGreg Roach    public function values(): array
123c2ed51d1SGreg Roach    {
124e7e5b015SGreg Roach        $values = [
125c2ed51d1SGreg Roach            ''              => '',
1263f810b5bSGreg Roach            'AFRIKAANS'     => (new LocaleAf())->endonym(),
1273f810b5bSGreg Roach            'ALBANIAN'      => (new LocaleSq())->endonym(),
1283f810b5bSGreg Roach            'AMHARIC'       => (new LocaleAm())->endonym(),
1293f810b5bSGreg Roach            'ANGLO-SAXON'   => (new LocaleAng())->endonym(),
1303f810b5bSGreg Roach            'ARABIC'        => (new LocaleAr())->endonym(),
1313f810b5bSGreg Roach            'ARMENIAN'      => (new LocaleHy())->endonym(),
1323f810b5bSGreg Roach            'ASSAMESE'      => (new LocaleAs())->endonym(),
1333f810b5bSGreg Roach            'BELORUSIAN'    => (new LocaleBe())->endonym(),
1343f810b5bSGreg Roach            'BENGALI'       => (new LocaleBn())->endonym(),
1353f810b5bSGreg Roach            //'BRAJ' => (new LocaleBra())->endonym(),
1363f810b5bSGreg Roach            'BULGARIAN'     => (new LocaleBg())->endonym(),
1373f810b5bSGreg Roach            'BURMESE'       => (new LocaleMy())->endonym(),
1383f810b5bSGreg Roach            'CANTONESE'     => (new LocaleYue())->endonym(),
1393f810b5bSGreg Roach            'CATALAN'       => (new LocaleCaEsValencia())->endonym(),
1403f810b5bSGreg Roach            'CATALAN_SPN'   => (new LocaleCa())->endonym(),
1413f810b5bSGreg Roach            'CHURCH-SLAVIC' => (new LocaleCu())->endonym(),
1423f810b5bSGreg Roach            'CZECH'         => (new LocaleCs())->endonym(),
1433f810b5bSGreg Roach            'DANISH'        => (new LocaleDa())->endonym(),
1443f810b5bSGreg Roach            //'DOGRI' => (new LocaleDoi())->endonym(),
1453f810b5bSGreg Roach            'DUTCH'         => (new LocaleNl())->endonym(),
1463f810b5bSGreg Roach            'ENGLISH'       => (new LocaleEn())->endonym(),
1473f810b5bSGreg Roach            'ESPERANTO'     => (new LocaleEo())->endonym(),
1483f810b5bSGreg Roach            'ESTONIAN'      => (new LocaleEt())->endonym(),
1493f810b5bSGreg Roach            'FAROESE'       => (new LocaleFo())->endonym(),
1503f810b5bSGreg Roach            'FINNISH'       => (new LocaleFi())->endonym(),
1513f810b5bSGreg Roach            'FRENCH'        => (new LocaleFr())->endonym(),
1523f810b5bSGreg Roach            'GEORGIAN'      => (new LocaleKa())->endonym(),
1533f810b5bSGreg Roach            'GERMAN'        => (new LocaleDe())->endonym(),
1543f810b5bSGreg Roach            'GREEK'         => (new LocaleEl())->endonym(),
1553f810b5bSGreg Roach            'GUJARATI'      => (new LocaleGu())->endonym(),
1563f810b5bSGreg Roach            'HAWAIIAN'      => (new LocaleHaw())->endonym(),
1573f810b5bSGreg Roach            'HEBREW'        => (new LocaleHe())->endonym(),
1583f810b5bSGreg Roach            'HINDI'         => (new LocaleHi())->endonym(),
1593f810b5bSGreg Roach            'HUNGARIAN'     => (new LocaleHu())->endonym(),
1603f810b5bSGreg Roach            'ICELANDIC'     => (new LocaleIs())->endonym(),
1613f810b5bSGreg Roach            'INDONESIAN'    => (new LocaleId())->endonym(),
1623f810b5bSGreg Roach            'ITALIAN'       => (new LocaleIt())->endonym(),
1633f810b5bSGreg Roach            'JAPANESE'      => (new LocaleJa())->endonym(),
1643f810b5bSGreg Roach            'KANNADA'       => (new LocaleKn())->endonym(),
1653f810b5bSGreg Roach            'KHMER'         => (new LocaleKm())->endonym(),
1663f810b5bSGreg Roach            'KONKANI'       => (new LocaleKok())->endonym(),
1673f810b5bSGreg Roach            'KOREAN'        => (new LocaleKo())->endonym(),
1683f810b5bSGreg Roach            //'LAHNDA' => (new LocaleLah())->endonym(),
1693f810b5bSGreg Roach            'LAO'           => (new LocaleLo())->endonym(),
1703f810b5bSGreg Roach            'LATVIAN'       => (new LocaleLv())->endonym(),
1713f810b5bSGreg Roach            'LITHUANIAN'    => (new LocaleLt())->endonym(),
1723f810b5bSGreg Roach            'MACEDONIAN'    => (new LocaleMk())->endonym(),
1733f810b5bSGreg Roach            //'MAITHILI' => (new LocaleMai())->endonym(),
1743f810b5bSGreg Roach            'MALAYALAM'     => (new LocaleMl())->endonym(),
1753f810b5bSGreg Roach            //'MANDRIN' => (new LocaleCmn())->endonym(),
1763f810b5bSGreg Roach            //'MANIPURI' => (new LocaleMni())->endonym(),
1773f810b5bSGreg Roach            'MARATHI'       => (new LocaleMr())->endonym(),
1783f810b5bSGreg Roach            //'MEWARI' => (new LocaleMtr())->endonym(),
1793f810b5bSGreg Roach            //'NAVAHO' => (new LocaleNv())->endonym(),
1803f810b5bSGreg Roach            'NEPALI'        => (new LocaleNe())->endonym(),
1813f810b5bSGreg Roach            'NORWEGIAN'     => (new LocaleNn())->endonym(),
1823f810b5bSGreg Roach            'ORIYA'         => (new LocaleOr())->endonym(),
1833f810b5bSGreg Roach            //'PAHARI' => (new LocalePhr())->endonym(),
1843f810b5bSGreg Roach            //'PALI' => (new LocalePi())->endonym(),
1853f810b5bSGreg Roach            'PANJABI'       => (new LocalePa())->endonym(),
1863f810b5bSGreg Roach            'PERSIAN'       => (new LocaleFa())->endonym(),
1873f810b5bSGreg Roach            'POLISH'        => (new LocalePl())->endonym(),
1883f810b5bSGreg Roach            'PORTUGUESE'    => (new LocalePt())->endonym(),
1893f810b5bSGreg Roach            //'PRAKRIT' => (new LocalePra())->endonym(),
1903f810b5bSGreg Roach            'PUSTO'         => (new LocalePs())->endonym(),
1913f810b5bSGreg Roach            //'RAJASTHANI' => (new LocaleRaj())->endonym(),
1923f810b5bSGreg Roach            'ROMANIAN'      => (new LocaleRo())->endonym(),
1933f810b5bSGreg Roach            'RUSSIAN'       => (new LocaleRu())->endonym(),
1943f810b5bSGreg Roach            //'SANSKRIT' => (new LocaleSa())->endonym(),
1953f810b5bSGreg Roach            'SERB'          => (new LocaleSr())->endonym(),
1963f810b5bSGreg Roach            //'SERBO_CROA' => (new LocaleHbs())->endonym(),
1973f810b5bSGreg Roach            'SLOVAK'        => (new LocaleSk())->endonym(),
1983f810b5bSGreg Roach            'SLOVENE'       => (new LocaleSl())->endonym(),
1993f810b5bSGreg Roach            'SPANISH'       => (new LocaleEs())->endonym(),
2003f810b5bSGreg Roach            'SWEDISH'       => (new LocaleSv())->endonym(),
2013f810b5bSGreg Roach            'TAGALOG'       => (new LocaleTl())->endonym(),
2023f810b5bSGreg Roach            'TAMIL'         => (new LocaleTa())->endonym(),
2033f810b5bSGreg Roach            'TELUGU'        => (new LocaleTe())->endonym(),
2043f810b5bSGreg Roach            'THAI'          => (new LocaleTh())->endonym(),
2053f810b5bSGreg Roach            'TIBETAN'       => (new LocaleBo())->endonym(),
2063f810b5bSGreg Roach            'TURKISH'       => (new LocaleTr())->endonym(),
2073f810b5bSGreg Roach            'UKRAINIAN'     => (new LocaleUk())->endonym(),
2083f810b5bSGreg Roach            'URDU'          => (new LocaleUr())->endonym(),
2093f810b5bSGreg Roach            'VIETNAMESE'    => (new LocaleVi())->endonym(),
2103f810b5bSGreg Roach            //'WENDIC' => (new LocaleWen())->endonym(),
2113f810b5bSGreg Roach            'YIDDISH'       => (new LocaleYi())->endonym(),
212c2ed51d1SGreg Roach        ];
213e7e5b015SGreg Roach
21437646143SGreg Roach        uasort($values, I18N::comparator());
215e7e5b015SGreg Roach
216e7e5b015SGreg Roach        return $values;
217c2ed51d1SGreg Roach    }
218c2ed51d1SGreg Roach}
219