Advertisement
KosIvantsov

write_untranslated2file.groovy

Jun 22nd, 2013
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.28 KB | None | 0 0
  1. /*
  2.  * #Purpose: Write all unique untranslated segments to a file
  3.  * #Files:   Writes 'untranslated.txt' in the current project's root
  4.  * #Details: http://wp.me/p3fHEs-4L
  5.  *
  6.  * @author   Kos Ivantsov
  7.  * @based on scripts by Yu Tang
  8.  * @date     2013-06-25
  9.  * @version  0.2
  10.  */
  11.  
  12. import static javax.swing.JOptionPane.*
  13. import static org.omegat.util.Platform.*
  14.  
  15. // abort if a project is not opened yet
  16. def prop = project.projectProperties
  17. if (!prop) {
  18.   final def title = 'Untranslated to File'
  19.   final def msg   = 'Please try again after you open a project.'
  20.   showMessageDialog null, msg, title, INFORMATION_MESSAGE
  21.   return
  22. }
  23.  
  24. def folder = prop.projectRoot
  25. def fileloc = folder+'/untranslated.txt'
  26. writefile = new File(fileloc)
  27.  
  28. writefile.write("", 'UTF-8')
  29. def count = 0
  30. project.projectFiles
  31. .each {
  32. //console.println "\n${it.filePath}"
  33. it.entries
  34. .findAll {!project.getTranslationInfo(it).isTranslated()}
  35. .each {count++; writefile.append "${it.srcText}\n",'UTF-8'}
  36. }
  37.  
  38. console.println "\nUntranslated segments found: $count"
  39. count = 0
  40. def lines = writefile.readLines()
  41. uniqline = lines.unique()
  42. writefile.write("",'UTF-8')
  43. uniqline.each {
  44. writefile.append "$it\n\n",'UTF8';
  45. }
  46. console.println "Unique untranslated segments written to file:  $uniqline.size"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement