ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Gettext\Languages\Exporter\Xml Class Reference
+ Inheritance diagram for Gettext\Languages\Exporter\Xml:
+ Collaboration diagram for Gettext\Languages\Exporter\Xml:

Static Public Member Functions

static getDescription ()
 
- Static Public Member Functions inherited from Gettext\Languages\Exporter\Exporter
static getExporters ($onlyForPublicUse=false)
 Return the list of all the available exporters. More...
 
static getExporterDescription ($exporterHandle)
 Return the description of a specific exporter. More...
 
static getExporterClassName ($exporterHandle)
 Returns the fully qualified class name of a exporter given its handle. More...
 
static toString ($languages, $options=null)
 Convert a list of Language instances to string. More...
 
static toFile ($languages, $filename, $options=null)
 Save the Language instances to a file. More...
 
static isForPublicUse ()
 Is this exporter for public use? More...
 
static getDescription ()
 Return a short description of the exporter. More...
 

Static Protected Member Functions

static toStringDo ($languages)
 
- Static Protected Member Functions inherited from Gettext\Languages\Exporter\Exporter
static toStringDo ($languages)
 Convert a list of Language instances to string. More...
 

Detailed Description

Definition at line 4 of file Xml.php.

Member Function Documentation

◆ getDescription()

static Gettext\Languages\Exporter\Xml::getDescription ( )
static
See also
Exporter::getDescription

Definition at line 50 of file Xml.php.

51  {
52  return 'Build an XML file - schema available at http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd';
53  }

◆ toStringDo()

static Gettext\Languages\Exporter\Xml::toStringDo (   $languages)
staticprotected
See also
Exporter::toStringDo

Definition at line 9 of file Xml.php.

References $xml.

10  {
11  $xml = new \DOMDocument('1.0', 'UTF-8');
12  $xml->loadXML('<languages
13  xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules"
14  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15  xsi:schemaLocation="https://github.com/mlocati/cldr-to-gettext-plural-rules http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd"
16  />');
17  $xLanguages = $xml->firstChild;
18  foreach ($languages as $language) {
19  $xLanguage = $xml->createElement('language');
20  $xLanguage->setAttribute('id', $language->id);
21  $xLanguage->setAttribute('name', $language->name);
22  if (isset($language->supersededBy)) {
23  $xLanguage->setAttribute('supersededBy', $language->supersededBy);
24  }
25  if (isset($language->script)) {
26  $xLanguage->setAttribute('script', $language->script);
27  }
28  if (isset($language->territory)) {
29  $xLanguage->setAttribute('territory', $language->territory);
30  }
31  if (isset($language->baseLanguage)) {
32  $xLanguage->setAttribute('baseLanguage', $language->baseLanguage);
33  }
34  $xLanguage->setAttribute('formula', $language->formula);
35  foreach ($language->categories as $category) {
36  $xCategory = $xml->createElement('category');
37  $xCategory->setAttribute('id', $category->id);
38  $xCategory->setAttribute('examples', $category->examples);
39  $xLanguage->appendChild($xCategory);
40  }
41  $xLanguages->appendChild($xLanguage);
42  }
43  $xml->formatOutput = true;
44 
45  return $xml->saveXML();
46  }
$xml
Definition: metadata.php:240

The documentation for this class was generated from the following file: