xref: /webtrees/app/Elements/LanguageId.php (revision 1da5dadd02c9f21e0a345e21a19b2c63ae792ed3)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 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\Localization\Locale\LocaleAf;
23use Fisharebest\Localization\Locale\LocaleAm;
24use Fisharebest\Localization\Locale\LocaleAng;
25use Fisharebest\Localization\Locale\LocaleAr;
26use Fisharebest\Localization\Locale\LocaleAs;
27use Fisharebest\Localization\Locale\LocaleBe;
28use Fisharebest\Localization\Locale\LocaleBg;
29use Fisharebest\Localization\Locale\LocaleBn;
30use Fisharebest\Localization\Locale\LocaleBo;
31use Fisharebest\Localization\Locale\LocaleCa;
32use Fisharebest\Localization\Locale\LocaleCaEsValencia;
33use Fisharebest\Localization\Locale\LocaleCs;
34use Fisharebest\Localization\Locale\LocaleCu;
35use Fisharebest\Localization\Locale\LocaleDa;
36use Fisharebest\Localization\Locale\LocaleDe;
37use Fisharebest\Localization\Locale\LocaleEl;
38use Fisharebest\Localization\Locale\LocaleEn;
39use Fisharebest\Localization\Locale\LocaleEo;
40use Fisharebest\Localization\Locale\LocaleEs;
41use Fisharebest\Localization\Locale\LocaleEt;
42use Fisharebest\Localization\Locale\LocaleFa;
43use Fisharebest\Localization\Locale\LocaleFi;
44use Fisharebest\Localization\Locale\LocaleFo;
45use Fisharebest\Localization\Locale\LocaleFr;
46use Fisharebest\Localization\Locale\LocaleGu;
47use Fisharebest\Localization\Locale\LocaleHaw;
48use Fisharebest\Localization\Locale\LocaleHe;
49use Fisharebest\Localization\Locale\LocaleHi;
50use Fisharebest\Localization\Locale\LocaleHu;
51use Fisharebest\Localization\Locale\LocaleHy;
52use Fisharebest\Localization\Locale\LocaleId;
53use Fisharebest\Localization\Locale\LocaleIs;
54use Fisharebest\Localization\Locale\LocaleIt;
55use Fisharebest\Localization\Locale\LocaleJa;
56use Fisharebest\Localization\Locale\LocaleKa;
57use Fisharebest\Localization\Locale\LocaleKm;
58use Fisharebest\Localization\Locale\LocaleKn;
59use Fisharebest\Localization\Locale\LocaleKo;
60use Fisharebest\Localization\Locale\LocaleKok;
61use Fisharebest\Localization\Locale\LocaleLo;
62use Fisharebest\Localization\Locale\LocaleLt;
63use Fisharebest\Localization\Locale\LocaleLv;
64use Fisharebest\Localization\Locale\LocaleMk;
65use Fisharebest\Localization\Locale\LocaleMl;
66use Fisharebest\Localization\Locale\LocaleMr;
67use Fisharebest\Localization\Locale\LocaleMy;
68use Fisharebest\Localization\Locale\LocaleNe;
69use Fisharebest\Localization\Locale\LocaleNl;
70use Fisharebest\Localization\Locale\LocaleNn;
71use Fisharebest\Localization\Locale\LocaleOr;
72use Fisharebest\Localization\Locale\LocalePa;
73use Fisharebest\Localization\Locale\LocalePl;
74use Fisharebest\Localization\Locale\LocalePs;
75use Fisharebest\Localization\Locale\LocalePt;
76use Fisharebest\Localization\Locale\LocaleRo;
77use Fisharebest\Localization\Locale\LocaleRu;
78use Fisharebest\Localization\Locale\LocaleSk;
79use Fisharebest\Localization\Locale\LocaleSl;
80use Fisharebest\Localization\Locale\LocaleSq;
81use Fisharebest\Localization\Locale\LocaleSr;
82use Fisharebest\Localization\Locale\LocaleSv;
83use Fisharebest\Localization\Locale\LocaleTa;
84use Fisharebest\Localization\Locale\LocaleTe;
85use Fisharebest\Localization\Locale\LocaleTh;
86use Fisharebest\Localization\Locale\LocaleTl;
87use Fisharebest\Localization\Locale\LocaleTr;
88use Fisharebest\Localization\Locale\LocaleUk;
89use Fisharebest\Localization\Locale\LocaleUr;
90use Fisharebest\Localization\Locale\LocaleVi;
91use Fisharebest\Localization\Locale\LocaleYi;
92use Fisharebest\Localization\Locale\LocaleYue;
93use Fisharebest\Webtrees\I18N;
94
95use function strtoupper;
96
97/**
98 * LANGUAGE_ID := {Size=1:15}
99 * The human language in which the data in the transmission is normally read or
100 * written. It is used primarily by programs to select language-specific
101 * sorting sequences and phonetic name matching algorithms.
102 */
103class LanguageId extends AbstractElement
104{
105    /**
106     * Convert a value to a canonical form.
107     *
108     * @param string $value
109     *
110     * @return string
111     */
112    public function canonical(string $value): string
113    {
114        return strtoupper(parent::canonical($value));
115    }
116
117
118    /**
119     * A list of controlled values for this element
120     *
121     * @return array<int|string,string>
122     */
123    public function values(): array
124    {
125        $values = [
126            ''              => '',
127            'AFRIKAANS'     => (new LocaleAf())->endonym(),
128            'ALBANIAN'      => (new LocaleSq())->endonym(),
129            'AMHARIC'       => (new LocaleAm())->endonym(),
130            'ANGLO-SAXON'   => (new LocaleAng())->endonym(),
131            'ARABIC'        => (new LocaleAr())->endonym(),
132            'ARMENIAN'      => (new LocaleHy())->endonym(),
133            'ASSAMESE'      => (new LocaleAs())->endonym(),
134            'BELORUSIAN'    => (new LocaleBe())->endonym(),
135            'BENGALI'       => (new LocaleBn())->endonym(),
136            //'BRAJ' => (new LocaleBra())->endonym(),
137            'BULGARIAN'     => (new LocaleBg())->endonym(),
138            'BURMESE'       => (new LocaleMy())->endonym(),
139            'CANTONESE'     => (new LocaleYue())->endonym(),
140            'CATALAN'       => (new LocaleCaEsValencia())->endonym(),
141            'CATALAN_SPN'   => (new LocaleCa())->endonym(),
142            'CHURCH-SLAVIC' => (new LocaleCu())->endonym(),
143            'CZECH'         => (new LocaleCs())->endonym(),
144            'DANISH'        => (new LocaleDa())->endonym(),
145            //'DOGRI' => (new LocaleDoi())->endonym(),
146            'DUTCH'         => (new LocaleNl())->endonym(),
147            'ENGLISH'       => (new LocaleEn())->endonym(),
148            'ESPERANTO'     => (new LocaleEo())->endonym(),
149            'ESTONIAN'      => (new LocaleEt())->endonym(),
150            'FAROESE'       => (new LocaleFo())->endonym(),
151            'FINNISH'       => (new LocaleFi())->endonym(),
152            'FRENCH'        => (new LocaleFr())->endonym(),
153            'GEORGIAN'      => (new LocaleKa())->endonym(),
154            'GERMAN'        => (new LocaleDe())->endonym(),
155            'GREEK'         => (new LocaleEl())->endonym(),
156            'GUJARATI'      => (new LocaleGu())->endonym(),
157            'HAWAIIAN'      => (new LocaleHaw())->endonym(),
158            'HEBREW'        => (new LocaleHe())->endonym(),
159            'HINDI'         => (new LocaleHi())->endonym(),
160            'HUNGARIAN'     => (new LocaleHu())->endonym(),
161            'ICELANDIC'     => (new LocaleIs())->endonym(),
162            'INDONESIAN'    => (new LocaleId())->endonym(),
163            'ITALIAN'       => (new LocaleIt())->endonym(),
164            'JAPANESE'      => (new LocaleJa())->endonym(),
165            'KANNADA'       => (new LocaleKn())->endonym(),
166            'KHMER'         => (new LocaleKm())->endonym(),
167            'KONKANI'       => (new LocaleKok())->endonym(),
168            'KOREAN'        => (new LocaleKo())->endonym(),
169            //'LAHNDA' => (new LocaleLah())->endonym(),
170            'LAO'           => (new LocaleLo())->endonym(),
171            'LATVIAN'       => (new LocaleLv())->endonym(),
172            'LITHUANIAN'    => (new LocaleLt())->endonym(),
173            'MACEDONIAN'    => (new LocaleMk())->endonym(),
174            //'MAITHILI' => (new LocaleMai())->endonym(),
175            'MALAYALAM'     => (new LocaleMl())->endonym(),
176            //'MANDRIN' => (new LocaleCmn())->endonym(),
177            //'MANIPURI' => (new LocaleMni())->endonym(),
178            'MARATHI'       => (new LocaleMr())->endonym(),
179            //'MEWARI' => (new LocaleMtr())->endonym(),
180            //'NAVAHO' => (new LocaleNv())->endonym(),
181            'NEPALI'        => (new LocaleNe())->endonym(),
182            'NORWEGIAN'     => (new LocaleNn())->endonym(),
183            'ORIYA'         => (new LocaleOr())->endonym(),
184            //'PAHARI' => (new LocalePhr())->endonym(),
185            //'PALI' => (new LocalePi())->endonym(),
186            'PANJABI'       => (new LocalePa())->endonym(),
187            'PERSIAN'       => (new LocaleFa())->endonym(),
188            'POLISH'        => (new LocalePl())->endonym(),
189            'PORTUGUESE'    => (new LocalePt())->endonym(),
190            //'PRAKRIT' => (new LocalePra())->endonym(),
191            'PUSTO'         => (new LocalePs())->endonym(),
192            //'RAJASTHANI' => (new LocaleRaj())->endonym(),
193            'ROMANIAN'      => (new LocaleRo())->endonym(),
194            'RUSSIAN'       => (new LocaleRu())->endonym(),
195            //'SANSKRIT' => (new LocaleSa())->endonym(),
196            'SERB'          => (new LocaleSr())->endonym(),
197            //'SERBO_CROA' => (new LocaleHbs())->endonym(),
198            'SLOVAK'        => (new LocaleSk())->endonym(),
199            'SLOVENE'       => (new LocaleSl())->endonym(),
200            'SPANISH'       => (new LocaleEs())->endonym(),
201            'SWEDISH'       => (new LocaleSv())->endonym(),
202            'TAGALOG'       => (new LocaleTl())->endonym(),
203            'TAMIL'         => (new LocaleTa())->endonym(),
204            'TELUGU'        => (new LocaleTe())->endonym(),
205            'THAI'          => (new LocaleTh())->endonym(),
206            'TIBETAN'       => (new LocaleBo())->endonym(),
207            'TURKISH'       => (new LocaleTr())->endonym(),
208            'UKRAINIAN'     => (new LocaleUk())->endonym(),
209            'URDU'          => (new LocaleUr())->endonym(),
210            'VIETNAMESE'    => (new LocaleVi())->endonym(),
211            //'WENDIC' => (new LocaleWen())->endonym(),
212            'YIDDISH'       => (new LocaleYi())->endonym(),
213        ];
214
215        uasort($values, I18N::comparator());
216
217        return $values;
218    }
219}
220