Development

#3102: xliff_formatting2.patch

You must first sign up to be able to contribute.

Ticket #3102: xliff_formatting2.patch

File xliff_formatting2.patch , 1.6 kB (added by nicolas, 10 months ago)

New patch which format newly created XLIFF files

Line 
1 Index: /Users/niko/www/vendor/symfony11/lib/i18n/sfMessageSource_XLIFF.class.php
2 ===================================================================
3 --- /Users/niko/www/vendor/symfony11/lib/i18n/sfMessageSource_XLIFF.class.php   (revision 7855)
4 +++ /Users/niko/www/vendor/symfony11/lib/i18n/sfMessageSource_XLIFF.class.php   (working copy)
5 @@ -75,9 +75,10 @@
6    /**
7     * Creates and returns a new DOMDocument instance
8     *
9 +   * @param  string  $xml_source  XML string
10     * @return DOMDocument
11     */
12 -  protected static function createDOMDocument()
13 +  protected static function createDOMDocument($xml_source = null)
14    {
15      $dom = new DOMDocument();
16      $dom->formatOutput = true;
17 @@ -82,6 +83,10 @@
18      $dom = new DOMDocument();
19      $dom->formatOutput = true;
20      $dom->preserveWhiteSpace = false;
21 +    if (!is_null($xml_source) && is_string($xml_source))
22 +    {
23 +      $dom->loadXML($xml_source);
24 +    }
25      return $dom;
26    }
27  
28 @@ -186,6 +191,9 @@
29      $fileNode = $xpath->query('//file')->item(0);
30      $fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
31  
32 +    // Format document from current source (DOMPHP can't do this one shot)
33 +    $dom = self::createDOMDocument($dom->saveXML());
34 +
35      // save it and clear the cache for this variant
36      $dom->save($filename);
37      if ($this->cache)
38 @@ -391,7 +399,9 @@
39        throw new sfException(sprintf("Unable to create directory %s.", $dir));
40      }
41  
42 -    file_put_contents($file, $this->getTemplate($catalogue));
43 +    $dom = self::createDOMDocument();
44 +    $dom->loadXML($this->getTemplate($catalogue));
45 +    file_put_contents($file, $dom->saveXML());
46      chmod($file, 0777);
47  
48      return array($variant, $file);