|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees: online genealogy |
|
5
|
|
|
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
declare(strict_types=1); |
|
19
|
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees\GedcomCode; |
|
21
|
|
|
|
|
22
|
|
|
use Fisharebest\Localization\Locale; |
|
23
|
|
|
|
|
24
|
|
|
use function array_search; |
|
25
|
|
|
use function uasort; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class GedcomCodeLang - Functions and logic for GEDCOM "LANG" codes |
|
29
|
|
|
*/ |
|
30
|
|
|
class GedcomCodeLang |
|
31
|
|
|
{ |
|
32
|
|
|
private const LANGUAGE_IDS = [ |
|
33
|
|
|
'am' => 'Amharic', |
|
34
|
|
|
'ang' => 'Anglo-Saxon', |
|
35
|
|
|
'ar' => 'Arabic', |
|
36
|
|
|
'hy' => 'Armenian', |
|
37
|
|
|
'as' => 'Assamese', |
|
38
|
|
|
'be' => 'Belorusian', |
|
39
|
|
|
'bn' => 'Bengali', |
|
40
|
|
|
'bra' => 'Braj', |
|
41
|
|
|
'bg' => 'Bulgarian', |
|
42
|
|
|
'my' => 'Burmese', |
|
43
|
|
|
'yue' => 'Cantonese', |
|
44
|
|
|
'ca-valencia' => 'Catalan', |
|
45
|
|
|
'ca' => 'Catalan_Spn', |
|
46
|
|
|
'cu' => 'Church-Slavic', |
|
47
|
|
|
'cs' => 'Czech', |
|
48
|
|
|
'da' => 'Danish', |
|
49
|
|
|
'doi' => 'Dogri', |
|
50
|
|
|
'nl' => 'Dutch', |
|
51
|
|
|
'en' => 'English', |
|
52
|
|
|
'eo' => 'Esperanto', |
|
53
|
|
|
'et' => 'Estonian', |
|
54
|
|
|
'fo' => 'Faroese', |
|
55
|
|
|
'fi' => 'Finnish', |
|
56
|
|
|
'fr' => 'French', |
|
57
|
|
|
'ka' => 'Georgian', |
|
58
|
|
|
'de' => 'German', |
|
59
|
|
|
'el' => 'Greek', |
|
60
|
|
|
'gu' => 'Gujarati', |
|
61
|
|
|
'haw' => 'Hawaiian', |
|
62
|
|
|
'he' => 'Hebrew', |
|
63
|
|
|
'hi' => 'Hindi', |
|
64
|
|
|
'hu' => 'Hungarian', |
|
65
|
|
|
'is' => 'Icelandic', |
|
66
|
|
|
'id' => 'Indonesian', |
|
67
|
|
|
'it' => 'Italian', |
|
68
|
|
|
'ja' => 'Japanese', |
|
69
|
|
|
'kn' => 'Kannada', |
|
70
|
|
|
'km' => 'Khmer', |
|
71
|
|
|
'kok' => 'Konkani', |
|
72
|
|
|
'ko' => 'Korean', |
|
73
|
|
|
'lah' => 'Lahnda', |
|
74
|
|
|
'lo' => 'Lao', |
|
75
|
|
|
'lv' => 'Latvian', |
|
76
|
|
|
'lt' => 'Lithuanian', |
|
77
|
|
|
'mk' => 'Macedonian', |
|
78
|
|
|
'mai' => 'Maithili', |
|
79
|
|
|
'ml' => 'Malayalam', |
|
80
|
|
|
'cmn' => 'Mandrin', |
|
81
|
|
|
'mni' => 'Manipuri', |
|
82
|
|
|
'mr' => 'Marathi', |
|
83
|
|
|
'mtr' => 'Mewari', |
|
84
|
|
|
'nv' => 'Navaho', |
|
85
|
|
|
'ne' => 'Nepali', |
|
86
|
|
|
'nn' => 'Norwegian', |
|
87
|
|
|
'or' => 'Oriya', |
|
88
|
|
|
'phr' => 'Pahari', |
|
89
|
|
|
'pi' => 'Pali', |
|
90
|
|
|
'pa' => 'Panjabi', |
|
91
|
|
|
'fa' => 'Persian', |
|
92
|
|
|
'pl' => 'Polish', |
|
93
|
|
|
'pt' => 'Portuguese', |
|
94
|
|
|
'pra' => 'Prakrit', |
|
95
|
|
|
'ps' => 'Pusto', |
|
96
|
|
|
'raj' => 'Rajasthani', |
|
97
|
|
|
'ro' => 'Romanian', |
|
98
|
|
|
'ru' => 'Russian', |
|
99
|
|
|
'sa' => 'Sanskrit', |
|
100
|
|
|
'sr' => 'Serb', |
|
101
|
|
|
'hbs' => 'Serbo_Croa', |
|
102
|
|
|
'sk' => 'Slovak', |
|
103
|
|
|
'sl' => 'Slovene', |
|
104
|
|
|
'es' => 'Spanish', |
|
105
|
|
|
'sv' => 'Swedish', |
|
106
|
|
|
'tl' => 'Tagalog', |
|
107
|
|
|
'ta' => 'Tamil', |
|
108
|
|
|
'te' => 'Telugu', |
|
109
|
|
|
'th' => 'Thai', |
|
110
|
|
|
'bo' => 'Tibetan', |
|
111
|
|
|
'tr' => 'Turkish', |
|
112
|
|
|
'uk' => 'Ukrainian', |
|
113
|
|
|
'ur' => 'Urdu', |
|
114
|
|
|
'vi' => 'Vietnamese', |
|
115
|
|
|
'wen' => 'Wendic', |
|
116
|
|
|
'yi' => 'Yiddish', |
|
117
|
|
|
]; |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Display value for a language tag. |
|
121
|
|
|
* |
|
122
|
|
|
* @param string $type |
|
123
|
|
|
* |
|
124
|
|
|
* @return string |
|
125
|
|
|
*/ |
|
126
|
|
|
public static function getValue(string $type): string |
|
127
|
|
|
{ |
|
128
|
|
|
$code = array_search($type, self::LANGUAGE_IDS, true); |
|
129
|
|
|
|
|
130
|
|
|
if ($code === false) { |
|
131
|
|
|
return $type; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
try { |
|
135
|
|
|
return Locale::create($code)->endonym(); |
|
136
|
|
|
} catch (\DomainException $ex) { |
|
137
|
|
|
return $type; |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* A list of all possible values for LANG fields. |
|
143
|
|
|
* |
|
144
|
|
|
* @return string[] |
|
145
|
|
|
*/ |
|
146
|
|
|
public static function getValues(): array |
|
147
|
|
|
{ |
|
148
|
|
|
$values = []; |
|
149
|
|
|
foreach (self::LANGUAGE_IDS as $value) { |
|
150
|
|
|
$values[$value] = self::getValue($value); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp'); |
|
154
|
|
|
|
|
155
|
|
|
return $values; |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|