Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Define and replace translations on the fly System 10.6
Snow Leopard only hintAs a professional translator, I was looking for a way to substitute highlighted text with existing translations in any kind of document I was working with. With the new way of creating Services in 10.6, this was easily achieved.

Create a new service in Automator and select 'Service receives text in any application' and check 'Replaces selected text' in the header of the Automator window. Then drag the action Run Shell Scrip to the workflow. Set the 'Pass input' pop-up to as arguments. Copy the following two lines of code into the Automator action:
echo $* >> /Users/your_name/desired_path/AnteTrans.txt
echo $* | grep -oE x0x.+ | tail -c +5
Replace the your_name and desired_path values with those you'd like to use. Save the workflow as AnteTransFeed.workflow.

Now create a second service, with all the same settings, including the Run Shell Script action. Replace the code with this one line:
grep -i "$*" /Users/your_name/desired_path/AnteTrans.txt | grep -oE x0x.+ | tail -c +5
Save this workflow as AnteTransRead.workflow.

The first service (AnteTransFeed) feeds the dictionary file with a new line containing the original text and the translation. The highlighted text should be of the format Tisch x0x desk, where x0x serves as the separator between the original text and the translation of that text.

Control-clicking on the highlighted text brings up the context menu containing the AnteTransFeed service, making it simple to add new translations to your dictionary -- the new line is appended to the dictionary file AnteTrans.txt.

The second service (AnteTransRead) searches for the highlighted text in the dictionary file and substitutes it with the translation(s) found. It's also a Service in the context menu of the highlighted text. You can assign keyboard shortcuts for both services for faster usage.

[robg adds: These worked as described in my testing.]
  • Currently 2.32 / 5
  You rated: 4 / 5 (19 votes cast)

10.6: Define and replace translations on the fly | 3 comments | Create New Account
Click here to return to the '10.6: Define and replace translations on the fly' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Define and replace translations on the fly
Authored by: drewk on Dec 07, '09 11:38:23AM

This is a good hint. However, the first service seems a little more complicated (and subject to typos and mistakes) than just using a text editor or Excel to edit your dictionary and then only have the second service to do the replacements.

[ Reply to This | # ]
10.6: Define and replace translations on the fly
Authored by: kevans on Dec 08, '09 08:25:53AM

If you are willing to use Windows virtualization, there is commercial software available to do this and MUCH more. As a certified translator, I use Parallels to run MultiTrans and LogiTerm software for translation memory and pre-translation tasks. Acquiring them is a deductible business expense.

Edited on Dec 08, '09 08:26:45AM by kevans

[ Reply to This | # ]
10.6: Define and replace translations on the fly
Authored by: TvE on Dec 08, '09 12:39:13PM

you can replace "/Users/your_name" with "~" and avoid making a hardcoded script and in stead make it generic for any userů

[ Reply to This | # ]