/var/www/hkosl.com/demo_google/application/vendor/gettext/languages/src/Exporter/Xml.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Gettext\Languages\Exporter;

class 
Xml extends Exporter
{
    
/**
     * @see Exporter::toStringDo
     */
    
protected static function toStringDo($languages)
    {
        
$xml = new \DOMDocument('1.0''UTF-8');
        
$xml->loadXML('<languages
            xmlns="https://github.com/mlocati/cldr-to-gettext-plural-rules"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="https://github.com/mlocati/cldr-to-gettext-plural-rules http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd"
        />'
);
        
$xLanguages $xml->firstChild;
        foreach (
$languages as $language) {
            
$xLanguage $xml->createElement('language');
            
$xLanguage->setAttribute('id'$language->id);
            
$xLanguage->setAttribute('name'$language->name);
            if (isset(
$language->supersededBy)) {
                
$xLanguage->setAttribute('supersededBy'$language->supersededBy);
            }
            if (isset(
$language->script)) {
                
$xLanguage->setAttribute('script'$language->script);
            }
            if (isset(
$language->territory)) {
                
$xLanguage->setAttribute('territory'$language->territory);
            }
            if (isset(
$language->baseLanguage)) {
                
$xLanguage->setAttribute('baseLanguage'$language->baseLanguage);
            }
            
$xLanguage->setAttribute('formula'$language->formula);
            foreach (
$language->categories as $category) {
                
$xCategory $xml->createElement('category');
                
$xCategory->setAttribute('id'$category->id);
                
$xCategory->setAttribute('examples'$category->examples);
                
$xLanguage->appendChild($xCategory);
            }
            
$xLanguages->appendChild($xLanguage);
        }
        
$xml->formatOutput true;

        return 
$xml->saveXML();
    }
    
/**
     * @see Exporter::getDescription
     */
    
public static function getDescription()
    {
        return 
'Build an XML file - schema available at http://mlocati.github.io/cldr-to-gettext-plural-rules/GettextLanguages.xsd';
    }
}