1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,339 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-/** |
|
4 |
- * This file is part of the Carbon package. |
|
5 |
- * |
|
6 |
- * (c) Brian Nesbitt <brian@nesbot.com> |
|
7 |
- * |
|
8 |
- * For the full copyright and license information, please view the LICENSE |
|
9 |
- * file that was distributed with this source code. |
|
10 |
- */ |
|
11 |
-namespace Carbon; |
|
12 |
- |
|
13 |
-use JsonSerializable; |
|
14 |
- |
|
15 |
-class Language implements JsonSerializable |
|
16 |
-{ |
|
17 |
- /** |
|
18 |
- * @var array |
|
19 |
- */ |
|
20 |
- protected static $languagesNames; |
|
21 |
- |
|
22 |
- /** |
|
23 |
- * @var array |
|
24 |
- */ |
|
25 |
- protected static $regionsNames; |
|
26 |
- |
|
27 |
- /** |
|
28 |
- * @var string |
|
29 |
- */ |
|
30 |
- protected $id; |
|
31 |
- |
|
32 |
- /** |
|
33 |
- * @var string |
|
34 |
- */ |
|
35 |
- protected $code; |
|
36 |
- |
|
37 |
- /** |
|
38 |
- * @var string|null |
|
39 |
- */ |
|
40 |
- protected $variant; |
|
41 |
- |
|
42 |
- /** |
|
43 |
- * @var string|null |
|
44 |
- */ |
|
45 |
- protected $region; |
|
46 |
- |
|
47 |
- /** |
|
48 |
- * @var array |
|
49 |
- */ |
|
50 |
- protected $names; |
|
51 |
- |
|
52 |
- /** |
|
53 |
- * @var string |
|
54 |
- */ |
|
55 |
- protected $isoName; |
|
56 |
- |
|
57 |
- /** |
|
58 |
- * @var string |
|
59 |
- */ |
|
60 |
- protected $nativeName; |
|
61 |
- |
|
62 |
- public function __construct(string $id) |
|
63 |
- { |
|
64 |
- $this->id = str_replace('-', '_', $id); |
|
65 |
- $parts = explode('_', $this->id); |
|
66 |
- $this->code = $parts[0]; |
|
67 |
- |
|
68 |
- if (isset($parts[1])) { |
|
69 |
- if (!preg_match('/^[A-Z]+$/', $parts[1])) { |
|
70 |
- $this->variant = $parts[1]; |
|
71 |
- $parts[1] = $parts[2] ?? null; |
|
72 |
- } |
|
73 |
- if ($parts[1]) { |
|
74 |
- $this->region = $parts[1]; |
|
75 |
- } |
|
76 |
- } |
|
77 |
- } |
|
78 |
- |
|
79 |
- /** |
|
80 |
- * Get the list of the known languages. |
|
81 |
- * |
|
82 |
- * @return array |
|
83 |
- */ |
|
84 |
- public static function all() |
|
85 |
- { |
|
86 |
- if (!static::$languagesNames) { |
|
87 |
- static::$languagesNames = include __DIR__.'/List/languages.php'; |
|
88 |
- } |
|
89 |
- |
|
90 |
- return static::$languagesNames; |
|
91 |
- } |
|
92 |
- |
|
93 |
- /** |
|
94 |
- * Get the list of the known regions. |
|
95 |
- * |
|
96 |
- * @return array |
|
97 |
- */ |
|
98 |
- public static function regions() |
|
99 |
- { |
|
100 |
- if (!static::$regionsNames) { |
|
101 |
- static::$regionsNames = include __DIR__.'/List/regions.php'; |
|
102 |
- } |
|
103 |
- |
|
104 |
- return static::$regionsNames; |
|
105 |
- } |
|
106 |
- |
|
107 |
- /** |
|
108 |
- * Get both isoName and nativeName as an array. |
|
109 |
- * |
|
110 |
- * @return array |
|
111 |
- */ |
|
112 |
- public function getNames(): array |
|
113 |
- { |
|
114 |
- if (!$this->names) { |
|
115 |
- $this->names = static::all()[$this->code] ?? [ |
|
116 |
- 'isoName' => $this->code, |
|
117 |
- 'nativeName' => $this->code, |
|
118 |
- ]; |
|
119 |
- } |
|
120 |
- |
|
121 |
- return $this->names; |
|
122 |
- } |
|
123 |
- |
|
124 |
- /** |
|
125 |
- * Returns the original locale ID. |
|
126 |
- * |
|
127 |
- * @return string |
|
128 |
- */ |
|
129 |
- public function getId(): string |
|
130 |
- { |
|
131 |
- return $this->id; |
|
132 |
- } |
|
133 |
- |
|
134 |
- /** |
|
135 |
- * Returns the code of the locale "en"/"fr". |
|
136 |
- * |
|
137 |
- * @return string |
|
138 |
- */ |
|
139 |
- public function getCode(): string |
|
140 |
- { |
|
141 |
- return $this->code; |
|
142 |
- } |
|
143 |
- |
|
144 |
- /** |
|
145 |
- * Returns the variant code such as cyrl/latn. |
|
146 |
- * |
|
147 |
- * @return string|null |
|
148 |
- */ |
|
149 |
- public function getVariant(): ?string |
|
150 |
- { |
|
151 |
- return $this->variant; |
|
152 |
- } |
|
153 |
- |
|
154 |
- /** |
|
155 |
- * Returns the variant such as Cyrillic/Latin. |
|
156 |
- * |
|
157 |
- * @return string|null |
|
158 |
- */ |
|
159 |
- public function getVariantName(): ?string |
|
160 |
- { |
|
161 |
- if ($this->variant === 'Latn') { |
|
162 |
- return 'Latin'; |
|
163 |
- } |
|
164 |
- |
|
165 |
- if ($this->variant === 'Cyrl') { |
|
166 |
- return 'Cyrillic'; |
|
167 |
- } |
|
168 |
- |
|
169 |
- return $this->variant; |
|
170 |
- } |
|
171 |
- |
|
172 |
- /** |
|
173 |
- * Returns the region part of the locale. |
|
174 |
- * |
|
175 |
- * @return string|null |
|
176 |
- */ |
|
177 |
- public function getRegion(): ?string |
|
178 |
- { |
|
179 |
- return $this->region; |
|
180 |
- } |
|
181 |
- |
|
182 |
- /** |
|
183 |
- * Returns the region name for the current language. |
|
184 |
- * |
|
185 |
- * @return string|null |
|
186 |
- */ |
|
187 |
- public function getRegionName(): ?string |
|
188 |
- { |
|
189 |
- return $this->region ? (static::regions()[$this->region] ?? $this->region) : null; |
|
190 |
- } |
|
191 |
- |
|
192 |
- /** |
|
193 |
- * Returns the long ISO language name. |
|
194 |
- * |
|
195 |
- * @return string |
|
196 |
- */ |
|
197 |
- public function getFullIsoName(): string |
|
198 |
- { |
|
199 |
- if (!$this->isoName) { |
|
200 |
- $this->isoName = $this->getNames()['isoName']; |
|
201 |
- } |
|
202 |
- |
|
203 |
- return $this->isoName; |
|
204 |
- } |
|
205 |
- |
|
206 |
- /** |
|
207 |
- * Set the ISO language name. |
|
208 |
- * |
|
209 |
- * @param string $isoName |
|
210 |
- */ |
|
211 |
- public function setIsoName(string $isoName): self |
|
212 |
- { |
|
213 |
- $this->isoName = $isoName; |
|
214 |
- |
|
215 |
- return $this; |
|
216 |
- } |
|
217 |
- |
|
218 |
- /** |
|
219 |
- * Return the full name of the language in this language. |
|
220 |
- * |
|
221 |
- * @return string |
|
222 |
- */ |
|
223 |
- public function getFullNativeName(): string |
|
224 |
- { |
|
225 |
- if (!$this->nativeName) { |
|
226 |
- $this->nativeName = $this->getNames()['nativeName']; |
|
227 |
- } |
|
228 |
- |
|
229 |
- return $this->nativeName; |
|
230 |
- } |
|
231 |
- |
|
232 |
- /** |
|
233 |
- * Set the name of the language in this language. |
|
234 |
- * |
|
235 |
- * @param string $nativeName |
|
236 |
- */ |
|
237 |
- public function setNativeName(string $nativeName): self |
|
238 |
- { |
|
239 |
- $this->nativeName = $nativeName; |
|
240 |
- |
|
241 |
- return $this; |
|
242 |
- } |
|
243 |
- |
|
244 |
- /** |
|
245 |
- * Returns the short ISO language name. |
|
246 |
- * |
|
247 |
- * @return string |
|
248 |
- */ |
|
249 |
- public function getIsoName(): string |
|
250 |
- { |
|
251 |
- $name = $this->getFullIsoName(); |
|
252 |
- |
|
253 |
- return trim(strstr($name, ',', true) ?: $name); |
|
254 |
- } |
|
255 |
- |
|
256 |
- /** |
|
257 |
- * Get the short name of the language in this language. |
|
258 |
- * |
|
259 |
- * @return string |
|
260 |
- */ |
|
261 |
- public function getNativeName(): string |
|
262 |
- { |
|
263 |
- $name = $this->getFullNativeName(); |
|
264 |
- |
|
265 |
- return trim(strstr($name, ',', true) ?: $name); |
|
266 |
- } |
|
267 |
- |
|
268 |
- /** |
|
269 |
- * Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable. |
|
270 |
- * |
|
271 |
- * @return string |
|
272 |
- */ |
|
273 |
- public function getIsoDescription() |
|
274 |
- { |
|
275 |
- $region = $this->getRegionName(); |
|
276 |
- $variant = $this->getVariantName(); |
|
277 |
- |
|
278 |
- return $this->getIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
279 |
- } |
|
280 |
- |
|
281 |
- /** |
|
282 |
- * Get a string with short native name, region in parentheses if applicable, variant in parentheses if applicable. |
|
283 |
- * |
|
284 |
- * @return string |
|
285 |
- */ |
|
286 |
- public function getNativeDescription() |
|
287 |
- { |
|
288 |
- $region = $this->getRegionName(); |
|
289 |
- $variant = $this->getVariantName(); |
|
290 |
- |
|
291 |
- return $this->getNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
292 |
- } |
|
293 |
- |
|
294 |
- /** |
|
295 |
- * Get a string with long ISO name, region in parentheses if applicable, variant in parentheses if applicable. |
|
296 |
- * |
|
297 |
- * @return string |
|
298 |
- */ |
|
299 |
- public function getFullIsoDescription() |
|
300 |
- { |
|
301 |
- $region = $this->getRegionName(); |
|
302 |
- $variant = $this->getVariantName(); |
|
303 |
- |
|
304 |
- return $this->getFullIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
305 |
- } |
|
306 |
- |
|
307 |
- /** |
|
308 |
- * Get a string with long native name, region in parentheses if applicable, variant in parentheses if applicable. |
|
309 |
- * |
|
310 |
- * @return string |
|
311 |
- */ |
|
312 |
- public function getFullNativeDescription() |
|
313 |
- { |
|
314 |
- $region = $this->getRegionName(); |
|
315 |
- $variant = $this->getVariantName(); |
|
316 |
- |
|
317 |
- return $this->getFullNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
318 |
- } |
|
319 |
- |
|
320 |
- /** |
|
321 |
- * Returns the original locale ID. |
|
322 |
- * |
|
323 |
- * @return string |
|
324 |
- */ |
|
325 |
- public function __toString() |
|
326 |
- { |
|
327 |
- return $this->getId(); |
|
328 |
- } |
|
329 |
- |
|
330 |
- /** |
|
331 |
- * Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable. |
|
332 |
- * |
|
333 |
- * @return string |
|
334 |
- */ |
|
335 |
- public function jsonSerialize() |
|
336 |
- { |
|
337 |
- return $this->getIsoDescription(); |
|
338 |
- } |
|
339 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,339 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * This file is part of the Carbon package. |
|
5 |
+ * |
|
6 |
+ * (c) Brian Nesbitt <brian@nesbot.com> |
|
7 |
+ * |
|
8 |
+ * For the full copyright and license information, please view the LICENSE |
|
9 |
+ * file that was distributed with this source code. |
|
10 |
+ */ |
|
11 |
+namespace Carbon; |
|
12 |
+ |
|
13 |
+use JsonSerializable; |
|
14 |
+ |
|
15 |
+class Language implements JsonSerializable |
|
16 |
+{ |
|
17 |
+ /** |
|
18 |
+ * @var array |
|
19 |
+ */ |
|
20 |
+ protected static $languagesNames; |
|
21 |
+ |
|
22 |
+ /** |
|
23 |
+ * @var array |
|
24 |
+ */ |
|
25 |
+ protected static $regionsNames; |
|
26 |
+ |
|
27 |
+ /** |
|
28 |
+ * @var string |
|
29 |
+ */ |
|
30 |
+ protected $id; |
|
31 |
+ |
|
32 |
+ /** |
|
33 |
+ * @var string |
|
34 |
+ */ |
|
35 |
+ protected $code; |
|
36 |
+ |
|
37 |
+ /** |
|
38 |
+ * @var string|null |
|
39 |
+ */ |
|
40 |
+ protected $variant; |
|
41 |
+ |
|
42 |
+ /** |
|
43 |
+ * @var string|null |
|
44 |
+ */ |
|
45 |
+ protected $region; |
|
46 |
+ |
|
47 |
+ /** |
|
48 |
+ * @var array |
|
49 |
+ */ |
|
50 |
+ protected $names; |
|
51 |
+ |
|
52 |
+ /** |
|
53 |
+ * @var string |
|
54 |
+ */ |
|
55 |
+ protected $isoName; |
|
56 |
+ |
|
57 |
+ /** |
|
58 |
+ * @var string |
|
59 |
+ */ |
|
60 |
+ protected $nativeName; |
|
61 |
+ |
|
62 |
+ public function __construct(string $id) |
|
63 |
+ { |
|
64 |
+ $this->id = str_replace('-', '_', $id); |
|
65 |
+ $parts = explode('_', $this->id); |
|
66 |
+ $this->code = $parts[0]; |
|
67 |
+ |
|
68 |
+ if (isset($parts[1])) { |
|
69 |
+ if (!preg_match('/^[A-Z]+$/', $parts[1])) { |
|
70 |
+ $this->variant = $parts[1]; |
|
71 |
+ $parts[1] = $parts[2] ?? null; |
|
72 |
+ } |
|
73 |
+ if ($parts[1]) { |
|
74 |
+ $this->region = $parts[1]; |
|
75 |
+ } |
|
76 |
+ } |
|
77 |
+ } |
|
78 |
+ |
|
79 |
+ /** |
|
80 |
+ * Get the list of the known languages. |
|
81 |
+ * |
|
82 |
+ * @return array |
|
83 |
+ */ |
|
84 |
+ public static function all() |
|
85 |
+ { |
|
86 |
+ if (!static::$languagesNames) { |
|
87 |
+ static::$languagesNames = include __DIR__.'/List/languages.php'; |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ return static::$languagesNames; |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ /** |
|
94 |
+ * Get the list of the known regions. |
|
95 |
+ * |
|
96 |
+ * @return array |
|
97 |
+ */ |
|
98 |
+ public static function regions() |
|
99 |
+ { |
|
100 |
+ if (!static::$regionsNames) { |
|
101 |
+ static::$regionsNames = include __DIR__.'/List/regions.php'; |
|
102 |
+ } |
|
103 |
+ |
|
104 |
+ return static::$regionsNames; |
|
105 |
+ } |
|
106 |
+ |
|
107 |
+ /** |
|
108 |
+ * Get both isoName and nativeName as an array. |
|
109 |
+ * |
|
110 |
+ * @return array |
|
111 |
+ */ |
|
112 |
+ public function getNames(): array |
|
113 |
+ { |
|
114 |
+ if (!$this->names) { |
|
115 |
+ $this->names = static::all()[$this->code] ?? [ |
|
116 |
+ 'isoName' => $this->code, |
|
117 |
+ 'nativeName' => $this->code, |
|
118 |
+ ]; |
|
119 |
+ } |
|
120 |
+ |
|
121 |
+ return $this->names; |
|
122 |
+ } |
|
123 |
+ |
|
124 |
+ /** |
|
125 |
+ * Returns the original locale ID. |
|
126 |
+ * |
|
127 |
+ * @return string |
|
128 |
+ */ |
|
129 |
+ public function getId(): string |
|
130 |
+ { |
|
131 |
+ return $this->id; |
|
132 |
+ } |
|
133 |
+ |
|
134 |
+ /** |
|
135 |
+ * Returns the code of the locale "en"/"fr". |
|
136 |
+ * |
|
137 |
+ * @return string |
|
138 |
+ */ |
|
139 |
+ public function getCode(): string |
|
140 |
+ { |
|
141 |
+ return $this->code; |
|
142 |
+ } |
|
143 |
+ |
|
144 |
+ /** |
|
145 |
+ * Returns the variant code such as cyrl/latn. |
|
146 |
+ * |
|
147 |
+ * @return string|null |
|
148 |
+ */ |
|
149 |
+ public function getVariant(): ?string |
|
150 |
+ { |
|
151 |
+ return $this->variant; |
|
152 |
+ } |
|
153 |
+ |
|
154 |
+ /** |
|
155 |
+ * Returns the variant such as Cyrillic/Latin. |
|
156 |
+ * |
|
157 |
+ * @return string|null |
|
158 |
+ */ |
|
159 |
+ public function getVariantName(): ?string |
|
160 |
+ { |
|
161 |
+ if ($this->variant === 'Latn') { |
|
162 |
+ return 'Latin'; |
|
163 |
+ } |
|
164 |
+ |
|
165 |
+ if ($this->variant === 'Cyrl') { |
|
166 |
+ return 'Cyrillic'; |
|
167 |
+ } |
|
168 |
+ |
|
169 |
+ return $this->variant; |
|
170 |
+ } |
|
171 |
+ |
|
172 |
+ /** |
|
173 |
+ * Returns the region part of the locale. |
|
174 |
+ * |
|
175 |
+ * @return string|null |
|
176 |
+ */ |
|
177 |
+ public function getRegion(): ?string |
|
178 |
+ { |
|
179 |
+ return $this->region; |
|
180 |
+ } |
|
181 |
+ |
|
182 |
+ /** |
|
183 |
+ * Returns the region name for the current language. |
|
184 |
+ * |
|
185 |
+ * @return string|null |
|
186 |
+ */ |
|
187 |
+ public function getRegionName(): ?string |
|
188 |
+ { |
|
189 |
+ return $this->region ? (static::regions()[$this->region] ?? $this->region) : null; |
|
190 |
+ } |
|
191 |
+ |
|
192 |
+ /** |
|
193 |
+ * Returns the long ISO language name. |
|
194 |
+ * |
|
195 |
+ * @return string |
|
196 |
+ */ |
|
197 |
+ public function getFullIsoName(): string |
|
198 |
+ { |
|
199 |
+ if (!$this->isoName) { |
|
200 |
+ $this->isoName = $this->getNames()['isoName']; |
|
201 |
+ } |
|
202 |
+ |
|
203 |
+ return $this->isoName; |
|
204 |
+ } |
|
205 |
+ |
|
206 |
+ /** |
|
207 |
+ * Set the ISO language name. |
|
208 |
+ * |
|
209 |
+ * @param string $isoName |
|
210 |
+ */ |
|
211 |
+ public function setIsoName(string $isoName): self |
|
212 |
+ { |
|
213 |
+ $this->isoName = $isoName; |
|
214 |
+ |
|
215 |
+ return $this; |
|
216 |
+ } |
|
217 |
+ |
|
218 |
+ /** |
|
219 |
+ * Return the full name of the language in this language. |
|
220 |
+ * |
|
221 |
+ * @return string |
|
222 |
+ */ |
|
223 |
+ public function getFullNativeName(): string |
|
224 |
+ { |
|
225 |
+ if (!$this->nativeName) { |
|
226 |
+ $this->nativeName = $this->getNames()['nativeName']; |
|
227 |
+ } |
|
228 |
+ |
|
229 |
+ return $this->nativeName; |
|
230 |
+ } |
|
231 |
+ |
|
232 |
+ /** |
|
233 |
+ * Set the name of the language in this language. |
|
234 |
+ * |
|
235 |
+ * @param string $nativeName |
|
236 |
+ */ |
|
237 |
+ public function setNativeName(string $nativeName): self |
|
238 |
+ { |
|
239 |
+ $this->nativeName = $nativeName; |
|
240 |
+ |
|
241 |
+ return $this; |
|
242 |
+ } |
|
243 |
+ |
|
244 |
+ /** |
|
245 |
+ * Returns the short ISO language name. |
|
246 |
+ * |
|
247 |
+ * @return string |
|
248 |
+ */ |
|
249 |
+ public function getIsoName(): string |
|
250 |
+ { |
|
251 |
+ $name = $this->getFullIsoName(); |
|
252 |
+ |
|
253 |
+ return trim(strstr($name, ',', true) ?: $name); |
|
254 |
+ } |
|
255 |
+ |
|
256 |
+ /** |
|
257 |
+ * Get the short name of the language in this language. |
|
258 |
+ * |
|
259 |
+ * @return string |
|
260 |
+ */ |
|
261 |
+ public function getNativeName(): string |
|
262 |
+ { |
|
263 |
+ $name = $this->getFullNativeName(); |
|
264 |
+ |
|
265 |
+ return trim(strstr($name, ',', true) ?: $name); |
|
266 |
+ } |
|
267 |
+ |
|
268 |
+ /** |
|
269 |
+ * Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable. |
|
270 |
+ * |
|
271 |
+ * @return string |
|
272 |
+ */ |
|
273 |
+ public function getIsoDescription() |
|
274 |
+ { |
|
275 |
+ $region = $this->getRegionName(); |
|
276 |
+ $variant = $this->getVariantName(); |
|
277 |
+ |
|
278 |
+ return $this->getIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
279 |
+ } |
|
280 |
+ |
|
281 |
+ /** |
|
282 |
+ * Get a string with short native name, region in parentheses if applicable, variant in parentheses if applicable. |
|
283 |
+ * |
|
284 |
+ * @return string |
|
285 |
+ */ |
|
286 |
+ public function getNativeDescription() |
|
287 |
+ { |
|
288 |
+ $region = $this->getRegionName(); |
|
289 |
+ $variant = $this->getVariantName(); |
|
290 |
+ |
|
291 |
+ return $this->getNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
292 |
+ } |
|
293 |
+ |
|
294 |
+ /** |
|
295 |
+ * Get a string with long ISO name, region in parentheses if applicable, variant in parentheses if applicable. |
|
296 |
+ * |
|
297 |
+ * @return string |
|
298 |
+ */ |
|
299 |
+ public function getFullIsoDescription() |
|
300 |
+ { |
|
301 |
+ $region = $this->getRegionName(); |
|
302 |
+ $variant = $this->getVariantName(); |
|
303 |
+ |
|
304 |
+ return $this->getFullIsoName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
305 |
+ } |
|
306 |
+ |
|
307 |
+ /** |
|
308 |
+ * Get a string with long native name, region in parentheses if applicable, variant in parentheses if applicable. |
|
309 |
+ * |
|
310 |
+ * @return string |
|
311 |
+ */ |
|
312 |
+ public function getFullNativeDescription() |
|
313 |
+ { |
|
314 |
+ $region = $this->getRegionName(); |
|
315 |
+ $variant = $this->getVariantName(); |
|
316 |
+ |
|
317 |
+ return $this->getFullNativeName().($region ? ' ('.$region.')' : '').($variant ? ' ('.$variant.')' : ''); |
|
318 |
+ } |
|
319 |
+ |
|
320 |
+ /** |
|
321 |
+ * Returns the original locale ID. |
|
322 |
+ * |
|
323 |
+ * @return string |
|
324 |
+ */ |
|
325 |
+ public function __toString() |
|
326 |
+ { |
|
327 |
+ return $this->getId(); |
|
328 |
+ } |
|
329 |
+ |
|
330 |
+ /** |
|
331 |
+ * Get a string with short ISO name, region in parentheses if applicable, variant in parentheses if applicable. |
|
332 |
+ * |
|
333 |
+ * @return string |
|
334 |
+ */ |
|
335 |
+ public function jsonSerialize() |
|
336 |
+ { |
|
337 |
+ return $this->getIsoDescription(); |
|
338 |
+ } |
|
339 |
+} |