PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / gettext / languages / src / Exporter / Json.php

Json.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at vendor/gettext/languages/src/Exporter/Json.php

89 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Gettext\Languages\Exporter;
4
5 class Json extends Exporter
6 {
7 /**
8 * {@inheritdoc}
9 *
10 * @see \Gettext\Languages\Exporter\Exporter::getDescription()
11 */
12 public static function getDescription()
13 {
14 return 'Build a compressed JSON-encoded file';
15 }
16
17 /**
18 * {@inheritdoc}
19 *
20 * @see \Gettext\Languages\Exporter\Exporter::supportsFormulasWithAndWithoutParenthesis()
21 */
22 public static function supportsFormulasWithAndWithoutParenthesis()
23 {
24 return true;
25 }
26
27 /**
28 * Return the options for json_encode.
29 *
30 * @return int
31 */
32 protected static function getEncodeOptions()
33 {
34 $result = 0;
35 if (defined('\JSON_UNESCAPED_SLASHES')) {
36 $result |= \JSON_UNESCAPED_SLASHES;
37 }
38 if (defined('\JSON_UNESCAPED_UNICODE')) {
39 $result |= \JSON_UNESCAPED_UNICODE;
40 }
41
42 return $result;
43 }
44
45 /**
46 * {@inheritdoc}
47 *
48 * @see \Gettext\Languages\Exporter\Exporter::toStringDoWithOptions()
49 */
50 protected static function toStringDoWithOptions($languages, array $options)
51 {
52 $list = array();
53 foreach ($languages as $language) {
54 $item = array();
55 $item['name'] = $language->name;
56 if (isset($language->supersededBy)) {
57 $item['supersededBy'] = $language->supersededBy;
58 }
59 if (isset($language->script)) {
60 $item['script'] = $language->script;
61 }
62 if (isset($language->territory)) {
63 $item['territory'] = $language->territory;
64 }
65 if (isset($language->baseLanguage)) {
66 $item['baseLanguage'] = $language->baseLanguage;
67 }
68 if (!empty($options['both-formulas'])) {
69 $item['formulas'] = array(
70 'standard' => $language->buildFormula(true),
71 'php' => $language->formula,
72 );
73 } else {
74 $item['formula'] = $language->formula;
75 }
76 $item['plurals'] = count($language->categories);
77 $item['cases'] = array();
78 $item['examples'] = array();
79 foreach ($language->categories as $category) {
80 $item['cases'][] = $category->id;
81 $item['examples'][$category->id] = $category->examples;
82 }
83 $list[$language->id] = $item;
84 }
85
86 return json_encode($list, static::getEncodeOptions());
87 }
88 }
89