1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 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; 93 94use Fisharebest\Webtrees\I18N; 95 96use function preg_replace_callback; 97 98/** 99 * LANGUAGE_ID := {Size=1:15} 100 * The human language in which the data in the transmission is normally read or 101 * written. It is used primarily by programs to select language-specific 102 * sorting sequences and phonetic name matching algorithms. 103 */ 104class LanguageId extends AbstractElement 105{ 106 /** 107 * Convert a value to a canonical form. 108 * 109 * @param string $value 110 * 111 * @return string 112 */ 113 public function canonical(string $value): string 114 { 115 return preg_replace_callback('/[A-Za-z]+/', static function (array $match): string { 116 return ucwords($match[0]); 117 }, strtolower(parent::canonical($value))); 118 } 119 120 121 /** 122 * A list of controlled values for this element 123 * 124 * @return array<int|string,string> 125 */ 126 public function values(): array 127 { 128 $values = [ 129 '' => '', 130 'Afrikaans' => (new LocaleAf())->endonym(), 131 'Albanian' => (new LocaleSq())->endonym(), 132 'Amharic' => (new LocaleAm())->endonym(), 133 'Anglo-Saxon' => (new LocaleAng())->endonym(), 134 'Arabic' => (new LocaleAr())->endonym(), 135 'Armenian' => (new LocaleHy())->endonym(), 136 'Assamese' => (new LocaleAs())->endonym(), 137 'Belorusian' => (new LocaleBe())->endonym(), 138 'Bengali' => (new LocaleBn())->endonym(), 139 //'Braj' => (new LocaleBra())->endonym(), 140 'Bulgarian' => (new LocaleBg())->endonym(), 141 'Burmese' => (new LocaleMy())->endonym(), 142 'Cantonese' => (new LocaleYue())->endonym(), 143 'Catalan' => (new LocaleCaEsValencia())->endonym(), 144 'Catalan_Spn' => (new LocaleCa())->endonym(), 145 'Church-Slavic' => (new LocaleCu())->endonym(), 146 'Czech' => (new LocaleCs())->endonym(), 147 'Danish' => (new LocaleDa())->endonym(), 148 //'Dogri' => (new LocaleDoi())->endonym(), 149 'Dutch' => (new LocaleNl())->endonym(), 150 'English' => (new LocaleEn())->endonym(), 151 'Esperanto' => (new LocaleEo())->endonym(), 152 'Estonian' => (new LocaleEt())->endonym(), 153 'Faroese' => (new LocaleFo())->endonym(), 154 'Finnish' => (new LocaleFi())->endonym(), 155 'French' => (new LocaleFr())->endonym(), 156 'Georgian' => (new LocaleKa())->endonym(), 157 'German' => (new LocaleDe())->endonym(), 158 'Greek' => (new LocaleEl())->endonym(), 159 'Gujarati' => (new LocaleGu())->endonym(), 160 'Hawaiian' => (new LocaleHaw())->endonym(), 161 'Hebrew' => (new LocaleHe())->endonym(), 162 'Hindi' => (new LocaleHi())->endonym(), 163 'Hungarian' => (new LocaleHu())->endonym(), 164 'Icelandic' => (new LocaleIs())->endonym(), 165 'Indonesian' => (new LocaleId())->endonym(), 166 'Italian' => (new LocaleIt())->endonym(), 167 'Japanese' => (new LocaleJa())->endonym(), 168 'Kannada' => (new LocaleKn())->endonym(), 169 'Khmer' => (new LocaleKm())->endonym(), 170 'Konkani' => (new LocaleKok())->endonym(), 171 'Korean' => (new LocaleKo())->endonym(), 172 //'Lahnda' => (new LocaleLah())->endonym(), 173 'Lao' => (new LocaleLo())->endonym(), 174 'Latvian' => (new LocaleLv())->endonym(), 175 'Lithuanian' => (new LocaleLt())->endonym(), 176 'Macedonian' => (new LocaleMk())->endonym(), 177 //'Maithili' => (new LocaleMai())->endonym(), 178 'Malayalam' => (new LocaleMl())->endonym(), 179 //'Mandrin' => (new LocaleCmn())->endonym(), 180 //'Manipuri' => (new LocaleMni())->endonym(), 181 'Marathi' => (new LocaleMr())->endonym(), 182 //'Mewari' => (new LocaleMtr())->endonym(), 183 //'Navaho' => (new LocaleNv())->endonym(), 184 'Nepali' => (new LocaleNe())->endonym(), 185 'Norwegian' => (new LocaleNn())->endonym(), 186 'Oriya' => (new LocaleOr())->endonym(), 187 //'Pahari' => (new LocalePhr())->endonym(), 188 //'Pali' => (new LocalePi())->endonym(), 189 'Panjabi' => (new LocalePa())->endonym(), 190 'Persian' => (new LocaleFa())->endonym(), 191 'Polish' => (new LocalePl())->endonym(), 192 'Portuguese' => (new LocalePt())->endonym(), 193 //'Prakrit' => (new LocalePra())->endonym(), 194 'Pusto' => (new LocalePs())->endonym(), 195 //'Rajasthani' => (new LocaleRaj())->endonym(), 196 'Romanian' => (new LocaleRo())->endonym(), 197 'Russian' => (new LocaleRu())->endonym(), 198 //'Sanskrit' => (new LocaleSa())->endonym(), 199 'Serb' => (new LocaleSr())->endonym(), 200 //'Serbo_Croa' => (new LocaleHbs())->endonym(), 201 'Slovak' => (new LocaleSk())->endonym(), 202 'Slovene' => (new LocaleSl())->endonym(), 203 'Spanish' => (new LocaleEs())->endonym(), 204 'Swedish' => (new LocaleSv())->endonym(), 205 'Tagalog' => (new LocaleTl())->endonym(), 206 'Tamil' => (new LocaleTa())->endonym(), 207 'Telugu' => (new LocaleTe())->endonym(), 208 'Thai' => (new LocaleTh())->endonym(), 209 'Tibetan' => (new LocaleBo())->endonym(), 210 'Turkish' => (new LocaleTr())->endonym(), 211 'Ukrainian' => (new LocaleUk())->endonym(), 212 'Urdu' => (new LocaleUr())->endonym(), 213 'Vietnamese' => (new LocaleVi())->endonym(), 214 //'Wendic' => (new LocaleWen())->endonym(), 215 'Yiddish' => (new LocaleYi())->endonym(), 216 ]; 217 218 uasort($values, [I18N::class, 'strcasecmp']); 219 220 return $values; 221 222 } 223} 224