Skip to content

Instantly share code, notes, and snippets.

@yu-tang
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yu-tang/5a49abebdcfdf1bdd11a to your computer and use it in GitHub Desktop.
Save yu-tang/5a49abebdcfdf1bdd11a to your computer and use it in GitHub Desktop.
Allow to support Jython for OmegaT Scripting
/*
* Allow to support Jython for OmegaT Scripting
*
* Usage: step 1. Get embedding Jython from http://www.jython.org/
* step 2. Adjust config setting and run this script
* Note : It's enabling Jython just while current session.
* Hint : Put this script to <ScriptsDir>/application_startup folder
* to automatically execution at every time OmT launching.
* Caution: This script is very hacky. Proceed at your own risk.
*
* @author Yu Tang
* @date 2014-12-13
* @version 0.1
*/
//################## config start ##################
PATH_TO_JYTHON_JAR = /C:\Absolute\Path\To\Your\jython.jar/
//################## config end ##################
import org.omegat.gui.scripting.ScriptingWindow
import org.omegat.gui.scripting.ScriptsMonitor
// append jython.jar to class-path at runtime
cl = ScriptingWindow.class.classLoader
cl.appendToClassPathForInstrumentation PATH_TO_JYTHON_JAR
def win = ScriptingWindow.window
win.manager.init cl
// refresh scripts list - display .py files
def monitor = win.monitor
monitor.stop()
monitor = new ScriptsMonitor(win, win.m_scriptList, win.availableScriptExtensions)
monitor.start win.m_scriptsDirectory
// refresh supported scripting engine list - Do you see 'jython'?
console.println win.listScriptEngine()
return null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment