1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// +---------------------------------------------------------------------------+ |
4
|
|
|
// | This file is part of the Agavi package. | |
5
|
|
|
// | Copyright (c) 2005-2011 the Agavi Project. | |
6
|
|
|
// | | |
7
|
|
|
// | For the full copyright and license information, please view the LICENSE | |
8
|
|
|
// | file that was distributed with this source code. You can also view the | |
9
|
|
|
// | LICENSE file online at http://www.agavi.org/LICENSE.txt | |
10
|
|
|
// | vi: set noexpandtab: | |
11
|
|
|
// | Local Variables: | |
12
|
|
|
// | indent-tabs-mode: t | |
13
|
|
|
// | End: | |
14
|
|
|
// +---------------------------------------------------------------------------+ |
15
|
|
|
|
16
|
|
|
namespace Agavi\Translation; |
17
|
|
|
|
18
|
|
|
use Agavi\Core\Context; |
19
|
|
|
use Agavi\Date\Calendar; |
20
|
|
|
use Agavi\Exception\AgaviException; |
21
|
|
|
use Agavi\Util\ParameterHolder; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The locale saves all kind of info about a locale |
25
|
|
|
* |
26
|
|
|
* @package agavi |
27
|
|
|
* @subpackage translation |
28
|
|
|
* |
29
|
|
|
* @author Dominik del Bondio <[email protected]> |
30
|
|
|
* @copyright Authors |
31
|
|
|
* @copyright The Agavi Project |
32
|
|
|
* |
33
|
|
|
* @since 0.11.0 |
34
|
|
|
* |
35
|
|
|
* @version $Id$ |
36
|
|
|
*/ |
37
|
|
|
class Locale extends ParameterHolder |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @var Context A Context instance. |
41
|
|
|
*/ |
42
|
|
|
protected $context = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var array The data. |
46
|
|
|
*/ |
47
|
|
|
protected $data = array(); |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string The identifier of this locale. |
51
|
|
|
*/ |
52
|
|
|
protected $identifier = null; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Returns the locale option string containing the timezone option set |
56
|
|
|
* to the timezone of this calendar. |
57
|
|
|
* |
58
|
|
|
* @param Calendar|\DateTime|int $item The item to determine the timezone from |
59
|
|
|
* @param string $prefix The prefix which will be applied to the timezone option |
60
|
|
|
* string. Use ';' here if you intend to use several |
61
|
|
|
* locale options and append the result of this method |
62
|
|
|
* to your locale string. |
63
|
|
|
* |
64
|
|
|
* @return string Returns an empty string (NOT containing the $prefix) |
65
|
|
|
* if $item is invalid or no timezone could be determined |
66
|
|
|
* |
67
|
|
|
* @author Dominik del Bondio <[email protected]> |
68
|
|
|
* @since 1.0.0 |
69
|
|
|
*/ |
70
|
|
|
public static function getTimeZoneOptionString($item, $prefix = '@') |
71
|
|
|
{ |
72
|
|
|
$tzId = ''; |
73
|
|
|
if ($item instanceof Calendar) { |
74
|
|
|
$tzId = $item->getTimeZone()->getResolvedId(); |
75
|
|
|
} elseif ($item instanceof \DateTime) { |
76
|
|
|
$tzId = $item->getTimezone()->getName(); |
77
|
|
|
if (preg_match('/^[+-][0-9]+/', $tzId)) { |
78
|
|
|
$tzId = 'GMT' . $tzId; |
79
|
|
|
} |
80
|
|
|
} elseif (is_int($item)) { |
81
|
|
|
$tzId = 'UTC'; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if ($tzId) { |
85
|
|
|
return $prefix . 'timezone=' . $tzId; |
86
|
|
|
} else { |
87
|
|
|
return ''; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Initialize this Locale. |
93
|
|
|
* |
94
|
|
|
* @param Context $context The current application context. |
95
|
|
|
* @param array $parameters An associative array of initialization parameters. |
96
|
|
|
* @param string $identifier The identifier of the locale |
97
|
|
|
* @param array $data The locale data. |
98
|
|
|
* |
99
|
|
|
* @author Dominik del Bondio <[email protected]> |
100
|
|
|
* @author David Zülke <[email protected]> |
101
|
|
|
* @since 0.11.0 |
102
|
|
|
*/ |
103
|
|
|
public function initialize(Context $context, array $parameters = array(), $identifier, array $data = array()) |
104
|
|
|
{ |
105
|
|
|
$this->context = $context; |
106
|
|
|
$this->parameters = $parameters; |
107
|
|
|
|
108
|
|
|
$this->identifier = $identifier; |
109
|
|
|
$this->data = $data; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Retrieve the current application context. |
114
|
|
|
* |
115
|
|
|
* @return Context The current Context instance. |
116
|
|
|
* |
117
|
|
|
* @author Dominik del Bondio <[email protected]> |
118
|
|
|
* @since 0.11.0 |
119
|
|
|
*/ |
120
|
|
|
final public function getContext() |
121
|
|
|
{ |
122
|
|
|
return $this->context; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Returns the identifier of this locale |
127
|
|
|
* |
128
|
|
|
* @return string The identifier. |
129
|
|
|
* |
130
|
|
|
* @author Dominik del Bondio <[email protected]> |
131
|
|
|
* @since 0.11.0 |
132
|
|
|
*/ |
133
|
|
|
public function getIdentifier() |
134
|
|
|
{ |
135
|
|
|
return $this->identifier; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
////////////////////////////// Locale data ////////////////////////////////// |
139
|
|
|
|
140
|
|
|
public function getLocaleLanguage() |
141
|
|
|
{ |
142
|
|
|
return isset($this->data['locale']['language']) |
143
|
|
|
? $this->data['locale']['language'] |
144
|
|
|
: null; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function getLocaleTerritory() |
148
|
|
|
{ |
149
|
|
|
return isset($this->data['locale']['territory']) |
150
|
|
|
? $this->data['locale']['territory'] |
151
|
|
|
: null; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function getLocaleScript() |
155
|
|
|
{ |
156
|
|
|
return isset($this->data['locale']['script']) |
157
|
|
|
? $this->data['locale']['script'] |
158
|
|
|
: null; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function getLocaleVariant() |
162
|
|
|
{ |
163
|
|
|
return isset($this->data['locale']['variant']) |
164
|
|
|
? $this->data['locale']['variant'] |
165
|
|
|
: null; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getLocaleCurrency() |
169
|
|
|
{ |
170
|
|
|
return isset($this->data['locale']['currency']) |
171
|
|
|
? $this->data['locale']['currency'] |
172
|
|
|
: null; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function getLocaleCalendar() |
176
|
|
|
{ |
177
|
|
|
return isset($this->data['locale']['calendar']) |
178
|
|
|
? $this->data['locale']['calendar'] |
179
|
|
|
: $this->getDefaultCalendar(); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function getLocaleTimeZone() |
183
|
|
|
{ |
184
|
|
|
return isset($this->data['locale']['timezone']) |
185
|
|
|
? $this->data['locale']['timezone'] |
186
|
|
|
: null; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
///////////////////////////// locale names ////////////////////////////////// |
190
|
|
|
|
191
|
|
|
protected function generateCountryList() |
192
|
|
|
{ |
193
|
|
|
if (!isset($this->data['displayNames']['territories'])) { |
194
|
|
|
return; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
$terrs = $this->data['displayNames']['territories']; |
198
|
|
|
|
199
|
|
|
// we assume that the territories are the first items in the list |
200
|
|
|
$i = 0; |
201
|
|
|
foreach ($terrs as $key => $val) { |
202
|
|
|
// territories consist of 3 letter keys while countries only consist of 2 letter keys |
203
|
|
|
if (strlen($key) == 2) { |
204
|
|
|
break; |
205
|
|
|
} |
206
|
|
|
++$i; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
$this->data['displayNames']['countries'] = array_slice($terrs, $i, count($terrs) - $i, true); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
View Code Duplication |
public function getCountries() |
|
|
|
|
213
|
|
|
{ |
214
|
|
|
if (!isset($this->data['displayNames']['countries'])) { |
215
|
|
|
$this->generateCountryList(); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
return isset($this->data['displayNames']['countries']) |
219
|
|
|
? $this->data['displayNames']['countries'] |
220
|
|
|
: null; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
View Code Duplication |
public function getCountry($id) |
|
|
|
|
224
|
|
|
{ |
225
|
|
|
if (!isset($this->data['displayNames']['countries'])) { |
226
|
|
|
$this->generateCountryList(); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
return isset($this->data['displayNames']['countries'][$id]) |
230
|
|
|
? $this->data['displayNames']['countries'][$id] |
231
|
|
|
: null; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
public function getLanguages() |
235
|
|
|
{ |
236
|
|
|
return isset($this->data['displayNames']['languages']) |
237
|
|
|
? $this->data['displayNames']['languages'] |
238
|
|
|
: null; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
public function getLanguage($id) |
242
|
|
|
{ |
243
|
|
|
return isset($this->data['displayNames']['languages'][$id]) |
244
|
|
|
? $this->data['displayNames']['languages'][$id] |
245
|
|
|
: null; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
public function getScripts() |
249
|
|
|
{ |
250
|
|
|
return isset($this->data['displayNames']['scripts']) |
251
|
|
|
? $this->data['displayNames']['scripts'] |
252
|
|
|
: null; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
public function getScript($id) |
256
|
|
|
{ |
257
|
|
|
return isset($this->data['displayNames']['scripts'][$id]) |
258
|
|
|
? $this->data['displayNames']['scripts'][$id] |
259
|
|
|
: null; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function getTerritories() |
263
|
|
|
{ |
264
|
|
|
return isset($this->data['displayNames']['territories']) |
265
|
|
|
? $this->data['displayNames']['territories'] |
266
|
|
|
: null; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
public function getTerritory($id) |
270
|
|
|
{ |
271
|
|
|
return isset($this->data['displayNames']['territories'][$id]) |
272
|
|
|
? $this->data['displayNames']['territories'][$id] |
273
|
|
|
: null; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
public function getVariants() |
277
|
|
|
{ |
278
|
|
|
return isset($this->data['displayNames']['variants']) |
279
|
|
|
? $this->data['displayNames']['variants'] |
280
|
|
|
: null; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
public function getVariant($id) |
284
|
|
|
{ |
285
|
|
|
return isset($this->data['displayNames']['variants'][$id]) |
286
|
|
|
? $this->data['displayNames']['variants'][$id] |
287
|
|
|
: null; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
public function getMeasurementSystemNames() |
291
|
|
|
{ |
292
|
|
|
return isset($this->data['displayNames']['measurementSystemNames']) |
293
|
|
|
? $this->data['displayNames']['measurementSystemNames'] |
294
|
|
|
: null; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
public function getMeasurementSystemName($id) |
298
|
|
|
{ |
299
|
|
|
return isset($this->data['displayNames']['measurementSystemNames'][$id]) |
300
|
|
|
? $this->data['displayNames']['measurementSystemNames'][$id] |
301
|
|
|
: null; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
//////////////////////////////// layout ///////////////////////////////////// |
305
|
|
|
|
306
|
|
|
public function getLineOrientation() |
307
|
|
|
{ |
308
|
|
|
return isset($this->data['layout']['orientation']['lines']) |
309
|
|
|
? $this->data['layout']['orientation']['lines'] |
310
|
|
|
: null; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
public function getCharacterOrientation() |
314
|
|
|
{ |
315
|
|
|
return isset($this->data['layout']['orientation']['characters']) |
316
|
|
|
? $this->data['layout']['orientation']['characters'] |
317
|
|
|
: null; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
//////////////////////////////// delimiters ///////////////////////////////// |
321
|
|
|
|
322
|
|
|
public function getQuotationStart() |
323
|
|
|
{ |
324
|
|
|
return isset($this->data['delimiters']['quotationStart']) |
325
|
|
|
? $this->data['delimiters']['quotationStart'] |
326
|
|
|
: null; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
public function getQuotationEnd() |
330
|
|
|
{ |
331
|
|
|
return isset($this->data['delimiters']['quotationEnd']) |
332
|
|
|
? $this->data['delimiters']['quotationEnd'] |
333
|
|
|
: null; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
public function getAlternateQuotationStart() |
337
|
|
|
{ |
338
|
|
|
return isset($this->data['delimiters']['altQuotationStart']) |
339
|
|
|
? $this->data['delimiters']['altQuotationStart'] |
340
|
|
|
: null; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
public function getAlternateQuotationEnd() |
344
|
|
|
{ |
345
|
|
|
return isset($this->data['delimiters']['altQuotationEnd']) |
346
|
|
|
? $this->data['delimiters']['altQuotationEnd'] |
347
|
|
|
: null; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
//////////////////////////////// calendars ////////////////////////////////// |
351
|
|
|
|
352
|
|
|
public function getDefaultCalendar() |
353
|
|
|
{ |
354
|
|
|
return isset($this->data['calendars']['default']) |
355
|
|
|
? $this->data['calendars']['default'] |
356
|
|
|
: null; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
public function getCalendarMonthsWide($calendar) |
360
|
|
|
{ |
361
|
|
|
return isset($this->data['calendars'][$calendar]['months']['format']['wide']) |
362
|
|
|
? $this->data['calendars'][$calendar]['months']['format']['wide'] |
363
|
|
|
: null; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
public function getCalendarMonthWide($calendar, $month) |
367
|
|
|
{ |
368
|
|
|
return isset($this->data['calendars'][$calendar]['months']['format']['wide'][$month]) |
369
|
|
|
? $this->data['calendars'][$calendar]['months']['format']['wide'][$month] |
370
|
|
|
: null; |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
public function getCalendarMonthsAbbreviated($calendar) |
374
|
|
|
{ |
375
|
|
|
return isset($this->data['calendars'][$calendar]['months']['format']['abbreviated']) |
376
|
|
|
? $this->data['calendars'][$calendar]['months']['format']['abbreviated'] |
377
|
|
|
: null; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
public function getCalendarMonthAbbreviated($calendar, $month) |
381
|
|
|
{ |
382
|
|
|
return isset($this->data['calendars'][$calendar]['months']['format']['abbreviated'][$month]) |
383
|
|
|
? $this->data['calendars'][$calendar]['months']['format']['abbreviated'][$month] |
384
|
|
|
: null; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
public function getCalendarMonthsNarrow($calendar) |
388
|
|
|
{ |
389
|
|
|
return isset($this->data['calendars'][$calendar]['months']['stand-alone']['narrow']) |
390
|
|
|
? $this->data['calendars'][$calendar]['months']['stand-alone']['narrow'] |
391
|
|
|
: null; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
public function getCalendarMonthNarrow($calendar, $month) |
395
|
|
|
{ |
396
|
|
|
return isset($this->data['calendars'][$calendar]['months']['stand-alone']['narrow'][$month]) |
397
|
|
|
? $this->data['calendars'][$calendar]['months']['stand-alone']['narrow'][$month] |
398
|
|
|
: null; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
public function getCalendarDaysWide($calendar) |
402
|
|
|
{ |
403
|
|
|
return isset($this->data['calendars'][$calendar]['days']['format']['wide']) |
404
|
|
|
? $this->data['calendars'][$calendar]['days']['format']['wide'] |
405
|
|
|
: null; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
public function getCalendarDayWide($calendar, $day) |
409
|
|
|
{ |
410
|
|
|
return isset($this->data['calendars'][$calendar]['days']['format']['wide'][$day]) |
411
|
|
|
? $this->data['calendars'][$calendar]['days']['format']['wide'][$day] |
412
|
|
|
: null; |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
public function getCalendarDaysAbbreviated($calendar) |
416
|
|
|
{ |
417
|
|
|
return isset($this->data['calendars'][$calendar]['days']['format']['abbreviated']) |
418
|
|
|
? $this->data['calendars'][$calendar]['days']['format']['abbreviated'] |
419
|
|
|
: null; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
public function getCalendarDayAbbreviated($calendar, $day) |
423
|
|
|
{ |
424
|
|
|
return isset($this->data['calendars'][$calendar]['days']['format']['abbreviated'][$day]) |
425
|
|
|
? $this->data['calendars'][$calendar]['days']['format']['abbreviated'][$day] |
426
|
|
|
: null; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
public function getCalendarDaysNarrow($calendar) |
430
|
|
|
{ |
431
|
|
|
return isset($this->data['calendars'][$calendar]['days']['stand-alone']['narrow']) |
432
|
|
|
? $this->data['calendars'][$calendar]['days']['stand-alone']['narrow'] |
433
|
|
|
: null; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
public function getCalendarDayNarrow($calendar, $day) |
437
|
|
|
{ |
438
|
|
|
return isset($this->data['calendars'][$calendar]['days']['stand-alone']['narrow'][$day]) |
439
|
|
|
? $this->data['calendars'][$calendar]['days']['stand-alone']['narrow'][$day] |
440
|
|
|
: null; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
public function getCalendarQuartersWide($calendar) |
444
|
|
|
{ |
445
|
|
|
return isset($this->data['calendars'][$calendar]['quarters']['format']['wide']) |
446
|
|
|
? $this->data['calendars'][$calendar]['quarters']['format']['wide'] |
447
|
|
|
: null; |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
public function getCalendarQuarterWide($calendar, $quarter) |
451
|
|
|
{ |
452
|
|
|
return isset($this->data['calendars'][$calendar]['quarters']['format']['wide'][$quarter]) |
453
|
|
|
? $this->data['calendars'][$calendar]['quarters']['format']['wide'][$quarter] |
454
|
|
|
: null; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
public function getCalendarQuartersAbbreviated($calendar) |
458
|
|
|
{ |
459
|
|
|
return isset($this->data['calendars'][$calendar]['quarters']['format']['abbreviated']) |
460
|
|
|
? $this->data['calendars'][$calendar]['quarters']['format']['abbreviated'] |
461
|
|
|
: null; |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
public function getCalendarQuarterAbbreviated($calendar, $quarter) |
465
|
|
|
{ |
466
|
|
|
return isset($this->data['calendars'][$calendar]['quarters']['format']['abbreviated'][$quarter]) |
467
|
|
|
? $this->data['calendars'][$calendar]['quarters']['format']['abbreviated'][$quarter] |
468
|
|
|
: null; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
public function getCalendarQuartersNarrow($calendar) |
472
|
|
|
{ |
473
|
|
|
return isset($this->data['calendars'][$calendar]['quarters']['stand-alone']['narrow']) |
474
|
|
|
? $this->data['calendars'][$calendar]['quarters']['stand-alone']['narrow'] |
475
|
|
|
: null; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
public function getCalendarQuarterNarrow($calendar, $quarter) |
479
|
|
|
{ |
480
|
|
|
return isset($this->data['calendars'][$calendar]['quarters']['stand-alone']['narrow'][$quarter]) |
481
|
|
|
? $this->data['calendars'][$calendar]['quarters']['stand-alone']['narrow'][$quarter] |
482
|
|
|
: null; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
public function getCalendarAm($calendar) |
486
|
|
|
{ |
487
|
|
|
return isset($this->data['calendars'][$calendar]['am']) |
488
|
|
|
? $this->data['calendars'][$calendar]['am'] |
489
|
|
|
: null; |
490
|
|
|
} |
491
|
|
|
|
492
|
|
|
public function getCalendarPm($calendar) |
493
|
|
|
{ |
494
|
|
|
return isset($this->data['calendars'][$calendar]['pm']) |
495
|
|
|
? $this->data['calendars'][$calendar]['pm'] |
496
|
|
|
: null; |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
public function getCalendarErasWide($calendar) |
500
|
|
|
{ |
501
|
|
|
return isset($this->data['calendars'][$calendar]['eras']['wide']) |
502
|
|
|
? $this->data['calendars'][$calendar]['eras']['wide'] |
503
|
|
|
: null; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
public function getCalendarEraWide($calendar, $era) |
507
|
|
|
{ |
508
|
|
|
return isset($this->data['calendars'][$calendar]['eras']['wide'][$era]) |
509
|
|
|
? $this->data['calendars'][$calendar]['eras']['wide'][$era] |
510
|
|
|
: null; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
public function getCalendarErasAbbreviated($calendar) |
514
|
|
|
{ |
515
|
|
|
return isset($this->data['calendars'][$calendar]['eras']['abbreviated']) |
516
|
|
|
? $this->data['calendars'][$calendar]['eras']['abbreviated'] |
517
|
|
|
: null; |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
public function getCalendarEraAbbreviated($calendar, $era) |
521
|
|
|
{ |
522
|
|
|
return isset($this->data['calendars'][$calendar]['eras']['abbreviated'][$era]) |
523
|
|
|
? $this->data['calendars'][$calendar]['eras']['abbreviated'][$era] |
524
|
|
|
: null; |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
public function getCalendarErasNarrow($calendar) |
528
|
|
|
{ |
529
|
|
|
return isset($this->data['calendars'][$calendar]['eras']['narrow']) |
530
|
|
|
? $this->data['calendars'][$calendar]['eras']['narrow'] |
531
|
|
|
: null; |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
public function getCalendarEraNarrow($calendar, $era) |
535
|
|
|
{ |
536
|
|
|
return isset($this->data['calendars'][$calendar]['eras']['narrow'][$era]) |
537
|
|
|
? $this->data['calendars'][$calendar]['eras']['narrow'][$era] |
538
|
|
|
: null; |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
public function getCalendarDateFormatDefaultName($calendar) |
542
|
|
|
{ |
543
|
|
|
return isset($this->data['calendars'][$calendar]['dateFormats']['default']) |
544
|
|
|
? $this->data['calendars'][$calendar]['dateFormats']['default'] |
545
|
|
|
: null; |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
public function getCalendarDateFormats($calendar) |
549
|
|
|
{ |
550
|
|
|
return isset($this->data['calendars'][$calendar]['dateFormats']) |
551
|
|
|
? $this->data['calendars'][$calendar]['dateFormats'] |
552
|
|
|
: null; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
public function getCalendarDateFormat($calendar, $id) |
556
|
|
|
{ |
557
|
|
|
return isset($this->data['calendars'][$calendar]['dateFormats'][$id]) |
558
|
|
|
? $this->data['calendars'][$calendar]['dateFormats'][$id] |
559
|
|
|
: null; |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
public function getCalendarDateFormatPattern($calendar, $id) |
563
|
|
|
{ |
564
|
|
|
return isset($this->data['calendars'][$calendar]['dateFormats'][$id]['pattern']) |
565
|
|
|
? $this->data['calendars'][$calendar]['dateFormats'][$id]['pattern'] |
566
|
|
|
: null; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
public function getCalendarDateFormatDisplayName($calendar, $id) |
570
|
|
|
{ |
571
|
|
|
return isset($this->data['calendars'][$calendar]['dateFormats'][$id]['displayName']) |
572
|
|
|
? $this->data['calendars'][$calendar]['dateFormats'][$id]['displayName'] |
573
|
|
|
: null; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
public function getCalendarTimeFormatDefaultName($calendar) |
577
|
|
|
{ |
578
|
|
|
return isset($this->data['calendars'][$calendar]['timeFormats']['default']) |
579
|
|
|
? $this->data['calendars'][$calendar]['timeFormats']['default'] |
580
|
|
|
: null; |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
public function getCalendarTimeFormats($calendar) |
584
|
|
|
{ |
585
|
|
|
return isset($this->data['calendars'][$calendar]['timeFormats']) |
586
|
|
|
? $this->data['calendars'][$calendar]['timeFormats'] |
587
|
|
|
: null; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
public function getCalendarTimeFormat($calendar, $id) |
591
|
|
|
{ |
592
|
|
|
return isset($this->data['calendars'][$calendar]['timeFormats'][$id]) |
593
|
|
|
? $this->data['calendars'][$calendar]['timeFormats'][$id] |
594
|
|
|
: null; |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
public function getCalendarTimeFormatPattern($calendar, $id) |
598
|
|
|
{ |
599
|
|
|
return isset($this->data['calendars'][$calendar]['timeFormats'][$id]['pattern']) |
600
|
|
|
? $this->data['calendars'][$calendar]['timeFormats'][$id]['pattern'] |
601
|
|
|
: null; |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
public function getCalendarTimeFormatDisplayName($calendar, $id) |
605
|
|
|
{ |
606
|
|
|
return isset($this->data['calendars'][$calendar]['timeFormats'][$id]['displayName']) |
607
|
|
|
? $this->data['calendars'][$calendar]['timeFormats'][$id]['displayName'] |
608
|
|
|
: null; |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
public function getCalendarDateTimeFormatDefaultName($calendar) |
612
|
|
|
{ |
613
|
|
|
return isset($this->data['calendars'][$calendar]['dateTimeFormats']['default']) |
614
|
|
|
? $this->data['calendars'][$calendar]['dateTimeFormats']['default'] |
615
|
|
|
: null; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
public function getCalendarDateTimeFormats($calendar) |
619
|
|
|
{ |
620
|
|
|
return isset($this->data['calendars'][$calendar]['dateTimeFormats']['formats']) |
621
|
|
|
? $this->data['calendars'][$calendar]['dateTimeFormats']['formats'] |
622
|
|
|
: null; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
public function getCalendarDateTimeFormat($calendar, $id) |
626
|
|
|
{ |
627
|
|
|
return isset($this->data['calendars'][$calendar]['dateTimeFormats']['formats'][$id]) |
628
|
|
|
? $this->data['calendars'][$calendar]['dateTimeFormats']['formats'][$id] |
629
|
|
|
: null; |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
public function getCalendarFields($calendar, $id) |
|
|
|
|
633
|
|
|
{ |
634
|
|
|
return isset($this->data['calendars'][$calendar]['fields']) |
635
|
|
|
? $this->data['calendars'][$calendar]['fields'] |
636
|
|
|
: null; |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
public function getCalendarField($calendar, $id) |
640
|
|
|
{ |
641
|
|
|
return isset($this->data['calendars'][$calendar]['fields'][$id]) |
642
|
|
|
? $this->data['calendars'][$calendar]['fields'][$id] |
643
|
|
|
: null; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
public function getCalendarFieldDisplayName($calendar, $id) |
647
|
|
|
{ |
648
|
|
|
return isset($this->data['calendars'][$calendar]['fields'][$id]['displayName']) |
649
|
|
|
? $this->data['calendars'][$calendar]['fields'][$id]['displayName'] |
650
|
|
|
: null; |
651
|
|
|
} |
652
|
|
|
|
653
|
|
|
public function getCalendarFieldRelatives($calendar, $id) |
654
|
|
|
{ |
655
|
|
|
return isset($this->data['calendars'][$calendar]['fields'][$id]['relatives']) |
656
|
|
|
? $this->data['calendars'][$calendar]['fields'][$id]['relatives'] |
657
|
|
|
: null; |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
public function getCalendarFieldRelative($calendar, $id, $rId) |
661
|
|
|
{ |
662
|
|
|
return isset($this->data['calendars'][$calendar]['fields'][$id]['relatives'][$rId]) |
663
|
|
|
? $this->data['calendars'][$calendar]['fields'][$id]['relatives'][$rId] |
664
|
|
|
: null; |
665
|
|
|
} |
666
|
|
|
|
667
|
|
|
public function getTimeZoneHourFormat() |
668
|
|
|
{ |
669
|
|
|
return isset($this->data['timeZoneNames']['hourFormat']) |
670
|
|
|
? $this->data['timeZoneNames']['hourFormat'] |
671
|
|
|
: null; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
public function getTimeZoneHoursFormat() |
675
|
|
|
{ |
676
|
|
|
return isset($this->data['timeZoneNames']['hoursFormat']) |
677
|
|
|
? $this->data['timeZoneNames']['hoursFormat'] |
678
|
|
|
: null; |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
public function getTimeZoneGmtFormat() |
682
|
|
|
{ |
683
|
|
|
return isset($this->data['timeZoneNames']['gmtFormat']) |
684
|
|
|
? $this->data['timeZoneNames']['gmtFormat'] |
685
|
|
|
: null; |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
public function getTimeZoneRegionFormat() |
689
|
|
|
{ |
690
|
|
|
return isset($this->data['timeZoneNames']['regionFormat']) |
691
|
|
|
? $this->data['timeZoneNames']['regionFormat'] |
692
|
|
|
: null; |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
public function getTimeZoneFallbackFormat() |
696
|
|
|
{ |
697
|
|
|
return isset($this->data['timeZoneNames']['fallbackFormat']) |
698
|
|
|
? $this->data['timeZoneNames']['fallbackFormat'] |
699
|
|
|
: null; |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
public function getTimeZoneAbbreviationFormat() |
703
|
|
|
{ |
704
|
|
|
return isset($this->data['timeZoneNames']['abbreviationFormat']) |
705
|
|
|
? $this->data['timeZoneNames']['abbreviationFormat'] |
706
|
|
|
: null; |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
public function getTimeZoneLongGenericName($tz) |
710
|
|
|
{ |
711
|
|
|
return isset($this->data['timeZoneNames']['zones'][$tz]['long']['generic']) |
712
|
|
|
? $this->data['timeZoneNames']['zones'][$tz]['long']['generic'] |
713
|
|
|
: null; |
714
|
|
|
} |
715
|
|
|
|
716
|
|
|
public function getTimeZoneLongStandardName($tz) |
717
|
|
|
{ |
718
|
|
|
return isset($this->data['timeZoneNames']['zones'][$tz]['long']['standard']) |
719
|
|
|
? $this->data['timeZoneNames']['zones'][$tz]['long']['standard'] |
720
|
|
|
: null; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
public function getTimeZoneLongDaylightName($tz) |
724
|
|
|
{ |
725
|
|
|
return isset($this->data['timeZoneNames']['zones'][$tz]['long']['daylight']) |
726
|
|
|
? $this->data['timeZoneNames']['zones'][$tz]['long']['daylight'] |
727
|
|
|
: null; |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
public function getTimeZoneShortGenericName($tz) |
731
|
|
|
{ |
732
|
|
|
return isset($this->data['timeZoneNames']['zones'][$tz]['short']['generic']) |
733
|
|
|
? $this->data['timeZoneNames']['zones'][$tz]['short']['generic'] |
734
|
|
|
: null; |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
public function getTimeZoneShortStandardName($tz) |
738
|
|
|
{ |
739
|
|
|
return isset($this->data['timeZoneNames']['zones'][$tz]['short']['standard']) |
740
|
|
|
? $this->data['timeZoneNames']['zones'][$tz]['short']['standard'] |
741
|
|
|
: null; |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
public function getTimeZoneShortDaylightName($tz) |
745
|
|
|
{ |
746
|
|
|
return isset($this->data['timeZoneNames']['zones'][$tz]['short']['daylight']) |
747
|
|
|
? $this->data['timeZoneNames']['zones'][$tz]['short']['daylight'] |
748
|
|
|
: null; |
749
|
|
|
} |
750
|
|
|
|
751
|
|
|
public function getTimeZoneNames() |
752
|
|
|
{ |
753
|
|
|
return isset($this->data['timeZoneNames']['zones']) |
754
|
|
|
? $this->data['timeZoneNames']['zones'] |
755
|
|
|
: array(); |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
public function getNumberSymbolDecimal() |
759
|
|
|
{ |
760
|
|
|
return isset($this->data['numbers']['symbols']['decimal']) |
761
|
|
|
? $this->data['numbers']['symbols']['decimal'] |
762
|
|
|
: null; |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
public function getNumberSymbolGroup() |
766
|
|
|
{ |
767
|
|
|
return isset($this->data['numbers']['symbols']['group']) |
768
|
|
|
? $this->data['numbers']['symbols']['group'] |
769
|
|
|
: null; |
770
|
|
|
} |
771
|
|
|
|
772
|
|
|
public function getNumberSymbolList() |
773
|
|
|
{ |
774
|
|
|
return isset($this->data['numbers']['symbols']['list']) |
775
|
|
|
? $this->data['numbers']['symbols']['list'] |
776
|
|
|
: null; |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
public function getNumberSymbolPercentSign() |
780
|
|
|
{ |
781
|
|
|
return isset($this->data['numbers']['symbols']['percentSign']) |
782
|
|
|
? $this->data['numbers']['symbols']['percentSign'] |
783
|
|
|
: null; |
784
|
|
|
} |
785
|
|
|
|
786
|
|
|
public function getNumberSymbolZeroDigit() |
787
|
|
|
{ |
788
|
|
|
return isset($this->data['numbers']['symbols']['nativeZeroDigit']) |
789
|
|
|
? $this->data['numbers']['symbols']['nativeZeroDigit'] |
790
|
|
|
: null; |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
public function getNumberSymbolPatternDigit() |
794
|
|
|
{ |
795
|
|
|
return isset($this->data['numbers']['symbols']['patternDigit']) |
796
|
|
|
? $this->data['numbers']['symbols']['patternDigit'] |
797
|
|
|
: null; |
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
public function getNumberSymbolPlusSign() |
801
|
|
|
{ |
802
|
|
|
return isset($this->data['numbers']['symbols']['plusSign']) |
803
|
|
|
? $this->data['numbers']['symbols']['plusSign'] |
804
|
|
|
: null; |
805
|
|
|
} |
806
|
|
|
|
807
|
|
|
public function getNumberSymbolMinusSign() |
808
|
|
|
{ |
809
|
|
|
return isset($this->data['numbers']['symbols']['minusSign']) |
810
|
|
|
? $this->data['numbers']['symbols']['minusSign'] |
811
|
|
|
: null; |
812
|
|
|
} |
813
|
|
|
|
814
|
|
|
public function getNumberSymbolExponential() |
815
|
|
|
{ |
816
|
|
|
return isset($this->data['numbers']['symbols']['exponential']) |
817
|
|
|
? $this->data['numbers']['symbols']['exponential'] |
818
|
|
|
: null; |
819
|
|
|
} |
820
|
|
|
|
821
|
|
|
public function getNumberSymbolPerMille() |
822
|
|
|
{ |
823
|
|
|
return isset($this->data['numbers']['symbols']['perMille']) |
824
|
|
|
? $this->data['numbers']['symbols']['perMille'] |
825
|
|
|
: null; |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
public function getNumberSymbolInfinity() |
829
|
|
|
{ |
830
|
|
|
return isset($this->data['numbers']['symbols']['infinity']) |
831
|
|
|
? $this->data['numbers']['symbols']['infinity'] |
832
|
|
|
: null; |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
public function getNumberSymbolNaN() |
836
|
|
|
{ |
837
|
|
|
return isset($this->data['numbers']['symbols']['nan']) |
838
|
|
|
? $this->data['numbers']['symbols']['nan'] |
839
|
|
|
: null; |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
public function getDecimalFormat($dfId) |
843
|
|
|
{ |
844
|
|
|
return isset($this->data['numbers']['decimalFormats'][$dfId]) |
845
|
|
|
? $this->data['numbers']['decimalFormats'][$dfId] |
846
|
|
|
: null; |
847
|
|
|
} |
848
|
|
|
|
849
|
|
|
public function getDecimalFormats() |
850
|
|
|
{ |
851
|
|
|
return isset($this->data['numbers']['decimalFormats']) |
852
|
|
|
? $this->data['numbers']['decimalFormats'] |
853
|
|
|
: null; |
854
|
|
|
} |
855
|
|
|
|
856
|
|
|
public function getScientificFormat($sfId) |
857
|
|
|
{ |
858
|
|
|
return isset($this->data['numbers']['scientificFormats'][$sfId]) |
859
|
|
|
? $this->data['numbers']['scientificFormats'][$sfId] |
860
|
|
|
: null; |
861
|
|
|
} |
862
|
|
|
|
863
|
|
|
public function getScientificFormats() |
864
|
|
|
{ |
865
|
|
|
return isset($this->data['numbers']['scientificFormats']) |
866
|
|
|
? $this->data['numbers']['scientificFormats'] |
867
|
|
|
: null; |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
public function getPercentFormat($pfId) |
871
|
|
|
{ |
872
|
|
|
return isset($this->data['numbers']['percentFormats'][$pfId]) |
873
|
|
|
? $this->data['numbers']['percentFormats'][$pfId] |
874
|
|
|
: null; |
875
|
|
|
} |
876
|
|
|
|
877
|
|
|
public function getPercentFormats() |
878
|
|
|
{ |
879
|
|
|
return isset($this->data['numbers']['percentFormats']) |
880
|
|
|
? $this->data['numbers']['percentFormats'] |
881
|
|
|
: null; |
882
|
|
|
} |
883
|
|
|
|
884
|
|
|
public function getCurrencyFormat($cfId) |
885
|
|
|
{ |
886
|
|
|
return isset($this->data['numbers']['currencyFormats'][$cfId]) |
887
|
|
|
? $this->data['numbers']['currencyFormats'][$cfId] |
888
|
|
|
: null; |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
public function getCurrencyFormats() |
892
|
|
|
{ |
893
|
|
|
return isset($this->data['numbers']['currencyFormats']) |
894
|
|
|
? $this->data['numbers']['currencyFormats'] |
895
|
|
|
: null; |
896
|
|
|
} |
897
|
|
|
|
898
|
|
|
public function getCurrencySpacingBeforeCurrencyCurrencyMatch() |
899
|
|
|
{ |
900
|
|
|
return isset($this->data['numbers']['currencySpacing']['beforeCurrency']['currencyMatch']) |
901
|
|
|
? $this->data['numbers']['currencySpacing']['beforeCurrency']['currencyMatch'] |
902
|
|
|
: null; |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
public function getCurrencySpacingBeforeCurrencySurroundingMatch() |
906
|
|
|
{ |
907
|
|
|
return isset($this->data['numbers']['currencySpacing']['beforeCurrency']['surroundingMatch']) |
908
|
|
|
? $this->data['numbers']['currencySpacing']['beforeCurrency']['surroundingMatch'] |
909
|
|
|
: null; |
910
|
|
|
} |
911
|
|
|
|
912
|
|
|
public function getCurrencySpacingBeforeCurrencyInsertBetween() |
913
|
|
|
{ |
914
|
|
|
return isset($this->data['numbers']['currencySpacing']['beforeCurrency']['insertBetween']) |
915
|
|
|
? $this->data['numbers']['currencySpacing']['beforeCurrency']['insertBetween'] |
916
|
|
|
: null; |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
public function getCurrencySpacingAfterCurrencyCurrencyMatch() |
920
|
|
|
{ |
921
|
|
|
return isset($this->data['numbers']['currencySpacing']['afterCurrency']['currencyMatch']) |
922
|
|
|
? $this->data['numbers']['currencySpacing']['afterCurrency']['currencyMatch'] |
923
|
|
|
: null; |
924
|
|
|
} |
925
|
|
|
|
926
|
|
|
public function getCurrencySpacingAfterCurrencySurroundingMatch() |
927
|
|
|
{ |
928
|
|
|
return isset($this->data['numbers']['currencySpacing']['afterCurrency']['surroundingMatch']) |
929
|
|
|
? $this->data['numbers']['currencySpacing']['afterCurrency']['surroundingMatch'] |
930
|
|
|
: null; |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
public function getCurrencySpacingAfterCurrencyInsertBetween() |
934
|
|
|
{ |
935
|
|
|
return isset($this->data['numbers']['currencySpacing']['afterCurrency']['insertBetween']) |
936
|
|
|
? $this->data['numbers']['currencySpacing']['afterCurrency']['insertBetween'] |
937
|
|
|
: null; |
938
|
|
|
} |
939
|
|
|
|
940
|
|
|
public function getCurrencies() |
941
|
|
|
{ |
942
|
|
|
return isset($this->data['numbers']['currencies']) |
943
|
|
|
? $this->data['numbers']['currencies'] |
944
|
|
|
: null; |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
public function getCurrency($cId) |
948
|
|
|
{ |
949
|
|
|
return isset($this->data['numbers']['currencies'][$cId]) |
950
|
|
|
? $this->data['numbers']['currencies'][$cId] |
951
|
|
|
: null; |
952
|
|
|
} |
953
|
|
|
|
954
|
|
|
public function getCurrencyDisplayName($cId) |
955
|
|
|
{ |
956
|
|
|
return isset($this->data['numbers']['currencies'][$cId]['displayName']) |
957
|
|
|
? $this->data['numbers']['currencies'][$cId]['displayName'] |
958
|
|
|
: null; |
959
|
|
|
} |
960
|
|
|
|
961
|
|
|
public function getCurrencySymbol($cId) |
962
|
|
|
{ |
963
|
|
|
return isset($this->data['numbers']['currencies'][$cId]['symbol']) |
964
|
|
|
? $this->data['numbers']['currencies'][$cId]['symbol'] |
965
|
|
|
: null; |
966
|
|
|
} |
967
|
|
|
|
968
|
|
|
/** |
969
|
|
|
* Parses a locale identifier and returns its parts. |
970
|
|
|
* |
971
|
|
|
* @param string $identifier The locale identifier. |
972
|
|
|
* |
973
|
|
|
* @return array The parts of the identifier |
974
|
|
|
* |
975
|
|
|
* @author Dominik del Bondio <[email protected]> |
976
|
|
|
* @since 0.11.0 |
977
|
|
|
*/ |
978
|
|
|
public static function parseLocaleIdentifier($identifier) |
979
|
|
|
{ |
980
|
|
|
// the only important thing here is the forward assertion which is needed |
981
|
|
|
// so it doesn't match the first character of the territory |
982
|
|
|
$baseLocaleRx = '(?P<language>[^_@]{2,3})(?:_(?P<script>[^_@](?=@|_|$)|[^_@]{4,}))?(?:_(?P<territory>[^_@]{2,3}))?(?:_(?P<variant>[^@]+))?'; |
983
|
|
|
$optionsRx = '@(?P<options>.*)'; |
984
|
|
|
|
985
|
|
|
$localeRx = '#^(' . $baseLocaleRx . ')(' . $optionsRx . ')?$#'; |
986
|
|
|
|
987
|
|
|
$localeData = array( |
988
|
|
|
'language' => null, |
989
|
|
|
'script' => null, |
990
|
|
|
'territory' => null, |
991
|
|
|
'variant' => null, |
992
|
|
|
'options' => array(), |
993
|
|
|
'locale_str' => null, |
994
|
|
|
'option_str' => null, |
995
|
|
|
); |
996
|
|
|
|
997
|
|
|
if (preg_match($localeRx, $identifier, $match)) { |
998
|
|
|
$localeData['language'] = $match['language']; |
999
|
|
|
if (!empty($match['script'])) { |
1000
|
|
|
$localeData['script'] = $match['script']; |
1001
|
|
|
} |
1002
|
|
|
if (!empty($match['territory'])) { |
1003
|
|
|
$localeData['territory'] = $match['territory']; |
1004
|
|
|
} |
1005
|
|
|
if (!empty($match['variant'])) { |
1006
|
|
|
$localeData['variant'] = $match['variant']; |
1007
|
|
|
} |
1008
|
|
|
|
1009
|
|
|
if (!empty($match['options'])) { |
1010
|
|
|
$localeData['option_str'] = '@' . $match['options']; |
1011
|
|
|
|
1012
|
|
|
$options = explode(',', $match['options']); |
1013
|
|
|
foreach ($options as $option) { |
1014
|
|
|
$optData = explode('=', $option, 2); |
1015
|
|
|
$localeData['options'][$optData[0]] = $optData[1]; |
1016
|
|
|
} |
1017
|
|
|
} |
1018
|
|
|
|
1019
|
|
|
$localeData['locale_str'] = substr($identifier, 0, strcspn($identifier, '@')); |
1020
|
|
|
} else { |
1021
|
|
|
throw new AgaviException('Invalid locale identifier (' . $identifier . ') specified'); |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
return $localeData; |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
/** |
1028
|
|
|
* Returns all file names which need to be considered for the given |
1029
|
|
|
* identifier. |
1030
|
|
|
* |
1031
|
|
|
* @param mixed $localeIdentifier The locale identifier or the result of |
1032
|
|
|
* Locale::parseLocaleIdentifier |
1033
|
|
|
* |
1034
|
|
|
* @return array The filenames. |
1035
|
|
|
* |
1036
|
|
|
* @author Dominik del Bondio <[email protected]> |
1037
|
|
|
* @since 0.11.0 |
1038
|
|
|
*/ |
1039
|
|
|
public static function getLookupPath($localeIdentifier) |
1040
|
|
|
{ |
1041
|
|
|
if (is_array($localeIdentifier)) { |
1042
|
|
|
$localeInfo = $localeIdentifier; |
1043
|
|
|
} else { |
1044
|
|
|
$localeInfo = self::parseLocaleIdentifier($localeIdentifier); |
1045
|
|
|
} |
1046
|
|
|
|
1047
|
|
|
$scriptPart = null; |
|
|
|
|
1048
|
|
|
$path = $localeInfo['language']; |
1049
|
|
|
$paths[] = $path; |
|
|
|
|
1050
|
|
|
|
1051
|
|
|
if ($localeInfo['territory']) { |
1052
|
|
|
$path .= '_' . $localeInfo['territory']; |
1053
|
|
|
$paths[] = $path; |
1054
|
|
|
} |
1055
|
|
|
|
1056
|
|
|
if ($localeInfo['variant']) { |
1057
|
|
|
$path .= '_' . $localeInfo['variant']; |
1058
|
|
|
$paths[] = $path; |
1059
|
|
|
} |
1060
|
|
|
|
1061
|
|
|
if ($localeInfo['script']) { |
1062
|
|
|
$locPath = $localeInfo['language'] . '_' . $localeInfo['script']; |
1063
|
|
|
$paths[] = $locPath; |
1064
|
|
|
|
1065
|
|
|
if ($localeInfo['territory']) { |
1066
|
|
|
$locPath .= '_' . $localeInfo['territory']; |
1067
|
|
|
$paths[] = $locPath; |
1068
|
|
|
} |
1069
|
|
|
|
1070
|
|
|
if ($localeInfo['variant']) { |
1071
|
|
|
$locPath .= '_' . $localeInfo['variant']; |
1072
|
|
|
$paths[] = $locPath; |
1073
|
|
|
} |
1074
|
|
|
} |
1075
|
|
|
|
1076
|
|
|
return array_reverse($paths); |
1077
|
|
|
} |
1078
|
|
|
} |
1079
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.