OmegaT 2.0, shell scripts and Automator...

14 views
Skip to first unread message

Jean-Christophe Helary

unread,
Mar 13, 2009, 2:46:19 AM3/13/09
to Ome...@yahoogroups.com, mac-for-t...@googlegroups.com
Automator has a "run shell script" action that, even with only one
command, can be saved and run as an application.

That application can be called by any keyboard based application
launcher, Spotlight, Quicksilver etc.

Now, with the new "source export to text file" function in OmegaT, it
is possible to do a lot in the background.

I mentioned in an earlier thread that running a script in the
background to updat the contents of the system pasteboard did not seem
to work in OmegaT. After a few searches, I found that it seems to be a
Swing application issue. Java applications that are not based on Swing
do not seem to have that problem.

The solution I found was to change the front application and go back
to OmegaT.


Using Automator offers an elegant solution to this problem:

Instead of running a script in Terminal and changing the front app
only to update the pasteboard, call an Automator application that
contains the script, from OmegaT. OmegaT looks like it is the front
app, but while Automator runs it is Automators that is front.
Automator runs the script, updates the pasteboard and when it dies
(once the script is finished) you are back in front of OmegaT where
you can paste the contents of the pasteboard.

The following script is based on Robert's and takes the tags from the
source segment to puts them in the pasteboard:

=====================
tags=`grep -o "<.[^>]*>" /Users/suzume/Library/Preferences/OmegaT/
script/source.txt | tr -d "\n"`
echo $tags | pbcopy
=====================

Open Automator, put the "run shell script" action on an empty
workflow, save as an application (tags.app for ex).

Now, work in OmegaT. When you enter a new segment, OmegaT
automatically updates the contents of the source.txt file.

If the source has tags that you want to reproduce in the target, use
Spotlight/Quicksilver etc to call your "tags.app". It runs for half a
second to paste the tags into the pasteboard.

When you see the application has finished running, use "Cmd+P" to
paste the tags into your target segment.

It is slightly slower than a standard Cmd+V/Cmd+P but it is _much_
faster than copying the tags one by one (or removing the source
contents to isolate them).


Nice to see that Automator can be so easily combined with OmegaT !!!

Jean-Christophe Helary

------------------------------------
http://mac4translators.blogspot.com/

Jean-Christophe Helary

unread,
Mar 17, 2009, 10:57:41 AM3/17/09
to mac-for-t...@googlegroups.com, Ome...@yahoogroups.com
Thanks to members of the Mac-Talk list at Omnigroup, I was able to
find a faster wy to get to my data:

Create an Apple script that contains a "do shell script command", save
it as a application without a startup screen and call that from
Spotlight.

The Applescript solution is _much_ faster than the Automator one.

Now, it seems to also be possible to assign a shortcut to an
Applescript when the Script menu is displayed (Applescript Utility to
do that).

Put OmegaT to the front, Click on the Script mark in the Menu > Open
Scripts Folder > Open org.omegat.Main Scripts Folder. Put your
Applescript there.

Then go to System Preferences > Keyboard and assign a keyboard
shortcut to the Applescript that shows in the OmegaT script menu.

For some reason this does not work here (and not only for OmegaT, but
also for native apps, so I suspect my system is tired today...) but it
is supposed to...


> Jean-Christophe Helary
>
> ------------------------------------
> http://mac4translators.blogspot.com/

Jean-Christophe Helary

unread,
Mar 17, 2009, 11:25:15 AM3/17/09
to Mac for Translators, Ome...@yahoogroups.com

On mardi 17 mars 09, at 23:57, Jean-Christophe Helary wrote:

>
> Thanks to members of the Mac-Talk list at Omnigroup, I was able to
> find a faster wy to get to my data:
>
> Create an Apple script that contains a "do shell script command", save
> it as a application without a startup screen and call that from
> Spotlight.
>
> The Applescript solution is _much_ faster than the Automator one.

To be even faster on Intel machines, save as an "application bundle".
That makes the thing universal. The difference is quite noticeable.


>> Jean-Christophe Helary
Reply all
Reply to author
Forward
0 new messages