Advertisement
KosIvantsov

insert_match_no_tags.groovy

Jun 26th, 2013
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.81 KB | None | 0 0
  1. /*
  2.  * #Purpose: Insert tag-free match into current target
  3.  * #Details: http: // wp.me/p3fHEs-4W
  4.  *
  5.  * @author   Kos Ivantsov
  6.  * @date     2013-06-26
  7.  * @version  0.1
  8.  */
  9.  
  10. import static javax.swing.JOptionPane.*
  11. import static org.omegat.util.Platform.*
  12. import org.omegat.core.Core;
  13.  
  14. // abort if a project is not opened yet
  15. def prop = project.projectProperties
  16. if (!prop) {
  17.   final def title = 'Insert Match (no tags)'
  18.   final def msg   = 'Please try again after you open a project.'
  19.   showMessageDialog null, msg, title, INFORMATION_MESSAGE
  20.   return
  21. }
  22.  
  23. def match = Core.getMatcher()
  24. def near = match.getActiveMatch()
  25. if (near != null) {
  26.   def matchtranslation = "$near.translation"
  27.   matchtranslation = matchtranslation.replaceAll(/<\/?[a-z]+[0-9]* ?\/?>/, '')
  28.   editor.insertText(matchtranslation)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement