Last active
August 29, 2015 14:11
-
-
Save yu-tang/5a49abebdcfdf1bdd11a to your computer and use it in GitHub Desktop.
Allow to support Jython for OmegaT Scripting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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