PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.3.1
Defender Security – Malware Scanner, Login Security & Firewall v5.3.1
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 / Xml.php

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

61 lines 2.3 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 Xml extends Exporter
6 {
7 /**
8 * {@inheritdoc}
9 *
10 * @see \Gettext\Languages\Exporter\Exporter::getDescription()
11 */
12 public static function getDescription()
13 {
14 return 'Build an XML file - schema available at https://php-gettext.github.io/Languages/GettextLanguages.xsd';
15 }
16
17 /**
18 * {@inheritdoc}
19 *
20 * @see \Gettext\Languages\Exporter\Exporter::toStringDoWithOptions()
21 */
22 protected static function toStringDoWithOptions($languages, array $options)
23 {
24 $xml = new \DOMDocument('1.0', 'UTF-8');
25 $xml->loadXML('<languages
26 xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules"
27 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
28 xsi:schemaLocation="https://github.com/mlocati/cldr-to-gettext-plural-rules https://php-gettext.github.io/Languages/GettextLanguages.xsd"
29 />');
30 $xLanguages = $xml->firstChild;
31 foreach ($languages as $language) {
32 $xLanguage = $xml->createElement('language');
33 $xLanguage->setAttribute('id', $language->id);
34 $xLanguage->setAttribute('name', $language->name);
35 if (isset($language->supersededBy)) {
36 $xLanguage->setAttribute('supersededBy', $language->supersededBy);
37 }
38 if (isset($language->script)) {
39 $xLanguage->setAttribute('script', $language->script);
40 }
41 if (isset($language->territory)) {
42 $xLanguage->setAttribute('territory', $language->territory);
43 }
44 if (isset($language->baseLanguage)) {
45 $xLanguage->setAttribute('baseLanguage', $language->baseLanguage);
46 }
47 $xLanguage->setAttribute('formula', $language->formula);
48 foreach ($language->categories as $category) {
49 $xCategory = $xml->createElement('category');
50 $xCategory->setAttribute('id', $category->id);
51 $xCategory->setAttribute('examples', $category->examples);
52 $xLanguage->appendChild($xCategory);
53 }
54 $xLanguages->appendChild($xLanguage);
55 }
56 $xml->formatOutput = true;
57
58 return $xml->saveXML();
59 }
60 }
61