As 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 +5Replace 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 +5Save 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.]
•
[5,104 views]

