Quantcast
Viewing all articles
Browse latest Browse all 10

How can i automatic add ids to my trans-unit nodes in my XML Xliff Tanslation files?

When you validate you XML Xliff file you have often the problem that a trans-unit node has no or a already existing id. So i have wrote a small script for that problem.

fix_id.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
 
$doc = new DOMDocument();
$doc->load($argv[1]);
 
$xpath = new DOMXPath($doc);
 
$query = '//trans-unit';
 
$entries = $xpath->query($query);
foreach ($entries as $i => $entry) {
    $entry->setAttribute('id', $i+1);
}
 
$doc->save($argv[1]);

Execute the following command in your symfony1 root directory Image may be NSFW.
Clik here to view.
;)

for FILE in `find apps/*/i18n -name *\.xml`; do php fix_id.php $FILE; done;

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Image may be NSFW.
Clik here to view.
flattr this!


Viewing all articles
Browse latest Browse all 10

Trending Articles