|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ICanBoogie\CLDR\Supplemental; |
|
4
|
|
|
|
|
5
|
|
|
use Closure; |
|
6
|
|
|
use ICanBoogie\CLDR\AbstractSectionCollection; |
|
7
|
|
|
use ICanBoogie\CLDR\Warmable; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Representation of the "supplemental" section. |
|
11
|
|
|
* |
|
12
|
|
|
* <pre> |
|
13
|
|
|
* <?php |
|
14
|
|
|
* |
|
15
|
|
|
* use ICanBoogie\CLDR\Supplemental; |
|
16
|
|
|
* |
|
17
|
|
|
* $supplemental = new Supplemental($repository); |
|
18
|
|
|
* |
|
19
|
|
|
* echo $supplemental['calendarPreferenceData']['001']; // gregorian |
|
20
|
|
|
* </pre> |
|
21
|
|
|
* |
|
22
|
|
|
* @extends AbstractSectionCollection<string> |
|
23
|
|
|
*/ |
|
24
|
|
|
final class Supplemental extends AbstractSectionCollection implements Warmable |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Where _key_ is a property, matching a CLDR filename, and _value_ is an array path under "supplemental". |
|
28
|
|
|
*/ |
|
29
|
|
|
private const OFFSET_MAPPING = [ |
|
30
|
|
|
|
|
31
|
|
|
'aliases' => 'metadata/alias', |
|
32
|
|
|
'calendarData' => 'calendarData', |
|
33
|
|
|
'calendarPreferenceData' => 'calendarPreferenceData', |
|
34
|
|
|
'characterFallbacks' => 'characters/character-fallback', |
|
35
|
|
|
'codeMappings' => 'codeMappings', |
|
36
|
|
|
'currencyData' => 'currencyData', |
|
37
|
|
|
'dayPeriods' => 'dayPeriodRuleSet', |
|
38
|
|
|
'gender' => 'gender', |
|
39
|
|
|
'grammaticalFeatures' => 'grammaticalData', |
|
40
|
|
|
'languageData' => 'languageData', |
|
41
|
|
|
'languageGroups' => 'languageGroups', |
|
42
|
|
|
'languageMatching' => 'languageMatching', |
|
43
|
|
|
'likelySubtags' => 'likelySubtags', |
|
44
|
|
|
'measurementData' => 'measurementData', |
|
45
|
|
|
'metaZones' => 'metaZones', |
|
46
|
|
|
'numberingSystems' => 'numberingSystems', |
|
47
|
|
|
'ordinals' => 'plurals-type-ordinal', |
|
48
|
|
|
'parentLocales' => 'parentLocales/parentLocale', |
|
49
|
|
|
'pluralRanges' => 'plurals', |
|
50
|
|
|
'plurals' => 'plurals-type-cardinal', |
|
51
|
|
|
'primaryZones' => 'primaryZones', |
|
52
|
|
|
'references' => 'references', |
|
53
|
|
|
'territoryContainment' => 'territoryContainment', |
|
54
|
|
|
'territoryInfo' => 'territoryInfo', |
|
55
|
|
|
'timeData' => 'timeData', |
|
56
|
|
|
'unitPreferenceData' => 'unitPreferenceData', |
|
57
|
|
|
'weekData' => 'weekData', |
|
58
|
|
|
'windowsZones' => 'windowsZones', |
|
59
|
|
|
|
|
60
|
|
|
]; |
|
61
|
|
|
|
|
62
|
|
|
public function offsetExists(mixed $offset): bool |
|
63
|
|
|
{ |
|
64
|
|
|
return isset(self::OFFSET_MAPPING[$offset]); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function warm_up(Closure $progress): void |
|
68
|
|
|
{ |
|
69
|
|
|
$progress("Warming up supplemental:"); |
|
70
|
|
|
|
|
71
|
|
|
foreach (array_keys(self::OFFSET_MAPPING) as $offset) { |
|
72
|
|
|
$progress("- $offset"); |
|
73
|
|
|
$this->offsetGet($offset); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
protected function path_for(string $offset): string |
|
78
|
|
|
{ |
|
79
|
|
|
return "core/supplemental/$offset"; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
protected function data_path_for(string $offset): string |
|
83
|
|
|
{ |
|
84
|
|
|
return "supplemental/" . self::OFFSET_MAPPING[$offset]; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|