Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3.  
  4. /**
  5. * This script approves `trans-units` nodes in XLIFF files.
  6. *
  7. * If the approved property is not found, it is added with value "yes".
  8. * If the approved="no" property is found, value changes to "yes".
  9. * If the approved="yes" property is found, nothing is done.
  10. *
  11. * @usage:
  12. * // navigate to the directory contianing the XLIFF files
  13. * cd path/to/folder
  14. * // run the script like this:
  15. * php -f path/to/hide_dropped_segments.php file.xlf
  16. *
  17. * @author Mike Wagner <mwagner@ets.org>
  18. * @version 0.1
  19. */
  20.  
  21. #var_dump($argv[1]);die;
  22. $file = $argv[1];
  23. $text = file_get_contents($file, true);
  24.  
  25. $doc = new DOMDocument();
  26. $doc->loadXML($text);
  27.  
  28. $transunits = $doc->getElementsByTagName('trans-unit');
  29. foreach ($transunits as $tu) {
  30. $tu->setAttribute('approved', 'yes');
  31. }
  32.  
  33. $doc->formatOutput = true;
  34. $doc->encoding = 'UTF-8';
  35. $doc->save($file, LIBXML_NOEMPTYTAG);
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement