xref: /webtrees/app/Elements/LanguageId.php (revision 1270d2767576ed4a83917769b0ee3613e3b010bf)
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     * A list of controlled values for this element
119     *
120     * @return array<int|string,string>
121     */
122    public function values(): array
123    {
124        $values = [
125            ''              => '',
126            'AFRIKAANS'     => (new LocaleAf())->endonym(),
127            'ALBANIAN'      => (new LocaleSq())->endonym(),
128            'AMHARIC'       => (new LocaleAm())->endonym(),
129            'ANGLO-SAXON'   => (new LocaleAng())->endonym(),
130            'ARABIC'        => (new LocaleAr())->endonym(),
131            'ARMENIAN'      => (new LocaleHy())->endonym(),
132            'ASSAMESE'      => (new LocaleAs())->endonym(),
133            'BELORUSIAN'    => (new LocaleBe())->endonym(),
134            'BENGALI'       => (new LocaleBn())->endonym(),
135            //'BRAJ' => (new LocaleBra())->endonym(),
136            'BULGARIAN'     => (new LocaleBg())->endonym(),
137            'BURMESE'       => (new LocaleMy())->endonym(),
138            'CANTONESE'     => (new LocaleYue())->endonym(),
139            'CATALAN'       => (new LocaleCaEsValencia())->endonym(),
140            'CATALAN_SPN'   => (new LocaleCa())->endonym(),
141            'CHURCH-SLAVIC' => (new LocaleCu())->endonym(),
142            'CZECH'         => (new LocaleCs())->endonym(),
143            'DANISH'        => (new LocaleDa())->endonym(),
144            //'DOGRI' => (new LocaleDoi())->endonym(),
145            'DUTCH'         => (new LocaleNl())->endonym(),
146            'ENGLISH'       => (new LocaleEn())->endonym(),
147            'ESPERANTO'     => (new LocaleEo())->endonym(),
148            'ESTONIAN'      => (new LocaleEt())->endonym(),
149            'FAROESE'       => (new LocaleFo())->endonym(),
150            'FINNISH'       => (new LocaleFi())->endonym(),
151            'FRENCH'        => (new LocaleFr())->endonym(),
152            'GEORGIAN'      => (new LocaleKa())->endonym(),
153            'GERMAN'        => (new LocaleDe())->endonym(),
154            'GREEK'         => (new LocaleEl())->endonym(),
155            'GUJARATI'      => (new LocaleGu())->endonym(),
156            'HAWAIIAN'      => (new LocaleHaw())->endonym(),
157            'HEBREW'        => (new LocaleHe())->endonym(),
158            'HINDI'         => (new LocaleHi())->endonym(),
159            'HUNGARIAN'     => (new LocaleHu())->endonym(),
160            'ICELANDIC'     => (new LocaleIs())->endonym(),
161            'INDONESIAN'    => (new LocaleId())->endonym(),
162            'ITALIAN'       => (new LocaleIt())->endonym(),
163            'JAPANESE'      => (new LocaleJa())->endonym(),
164            'KANNADA'       => (new LocaleKn())->endonym(),
165            'KHMER'         => (new LocaleKm())->endonym(),
166            'KONKANI'       => (new LocaleKok())->endonym(),
167            'KOREAN'        => (new LocaleKo())->endonym(),
168            //'LAHNDA' => (new LocaleLah())->endonym(),
169            'LAO'           => (new LocaleLo())->endonym(),
170            'LATVIAN'       => (new LocaleLv())->endonym(),
171            'LITHUANIAN'    => (new LocaleLt())->endonym(),
172            'MACEDONIAN'    => (new LocaleMk())->endonym(),
173            //'MAITHILI' => (new LocaleMai())->endonym(),
174            'MALAYALAM'     => (new LocaleMl())->endonym(),
175            //'MANDRIN' => (new LocaleCmn())->endonym(),
176            //'MANIPURI' => (new LocaleMni())->endonym(),
177            'MARATHI'       => (new LocaleMr())->endonym(),
178            //'MEWARI' => (new LocaleMtr())->endonym(),
179            //'NAVAHO' => (new LocaleNv())->endonym(),
180            'NEPALI'        => (new LocaleNe())->endonym(),
181            'NORWEGIAN'     => (new LocaleNn())->endonym(),
182            'ORIYA'         => (new LocaleOr())->endonym(),
183            //'PAHARI' => (new LocalePhr())->endonym(),
184            //'PALI' => (new LocalePi())->endonym(),
185            'PANJABI'       => (new LocalePa())->endonym(),
186            'PERSIAN'       => (new LocaleFa())->endonym(),
187            'POLISH'        => (new LocalePl())->endonym(),
188            'PORTUGUESE'    => (new LocalePt())->endonym(),
189            //'PRAKRIT' => (new LocalePra())->endonym(),
190            'PUSTO'         => (new LocalePs())->endonym(),
191            //'RAJASTHANI' => (new LocaleRaj())->endonym(),
192            'ROMANIAN'      => (new LocaleRo())->endonym(),
193            'RUSSIAN'       => (new LocaleRu())->endonym(),
194            //'SANSKRIT' => (new LocaleSa())->endonym(),
195            'SERB'          => (new LocaleSr())->endonym(),
196            //'SERBO_CROA' => (new LocaleHbs())->endonym(),
197            'SLOVAK'        => (new LocaleSk())->endonym(),
198            'SLOVENE'       => (new LocaleSl())->endonym(),
199            'SPANISH'       => (new LocaleEs())->endonym(),
200            'SWEDISH'       => (new LocaleSv())->endonym(),
201            'TAGALOG'       => (new LocaleTl())->endonym(),
202            'TAMIL'         => (new LocaleTa())->endonym(),
203            'TELUGU'        => (new LocaleTe())->endonym(),
204            'THAI'          => (new LocaleTh())->endonym(),
205            'TIBETAN'       => (new LocaleBo())->endonym(),
206            'TURKISH'       => (new LocaleTr())->endonym(),
207            'UKRAINIAN'     => (new LocaleUk())->endonym(),
208            'URDU'          => (new LocaleUr())->endonym(),
209            'VIETNAMESE'    => (new LocaleVi())->endonym(),
210            //'WENDIC' => (new LocaleWen())->endonym(),
211            'YIDDISH'       => (new LocaleYi())->endonym(),
212        ];
213
214        uasort($values, I18N::comparator());
215
216        return $values;
217    }
218}
219