Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keyboard Shortcut - Launch Google Translate for Selected Text
#1
Often at my work, I need to translate documents received from international customers when English is not used. Typically, after selecting the text (from anywhere), you have to copy it (to the clipboard), start your browser, go to Google Translate, paste it (from the clipboard) in the query field, and then click a button to translate. This whole process can be very long and repetitive.

To solve this, I developed a quick AutoHotkey script to process the translation into Google Translate. I select the non-English text, then I activate the shortcut from Shortkeeper. Immediately after, Google Translate opens up in my internet browser and instantly shows me the English version of the text. Here's the AutoHotkey script to be used in Shortkeeper:

ClipSaved := ClipboardAll
Clipboard =
SendInput, ^c
ClipWait, 2
if ErrorLevel
{
  run % "https://translate.google.com/?js=n&sl=en&tl=fr"
}
else
{
  SelectedText := Trim(Clipboard)
SelectedText := StrReplace(SelectedText, "%", "%25")
SelectedText := StrReplace(SelectedText, "#", "%23")
SelectedText := StrReplace(SelectedText, "&", "%26")
SelectedText := StrReplace(SelectedText, "+", "%2b")
  SelectedText := StrReplace(SelectedText, """", "%22")
  SelectedText := StrReplace(SelectedText, A_SPACE, "%20")
  run % "https://translate.google.com/?js=n&sl=en&tl=fr&text=" . SelectedText
}
Clipboard := ClipSaved

Note that you can change the input and output language, to whatever language Google Translate supports, by changing the ''en'' and ''fr'' in the URL address to your preferred language code. In this example, I translate from English to French.

This shortcut is by far a game changer and ultimately saves me lots of precious time at work. Hope you enjoy it as much as I do!
Reply
#2
Thanks for sharing. The script works very well.

This short tutorial "https://forum.cedeq.com/showthread.php?tid=29" will help someone needing help to create a keyboard shortcut with ShortKeeper using AutoHotkey code.
Enterpad: For those who need more than a few shortcuts.

Reply
#3
Thanks for sharing .. but this script missed to hot key to work
for me i used "" ^t::""
that mean when i press (CTRL+ T) in same time . a translate page open in browser
Reply
#4
douh Wrote:Thanks for sharing .. but this script missed to hot key to work
for me i used ""  ^t::"" 
that mean when i press (CTRL+ T) in same time .  a translate page open in browser

There is no need to add anything in the code as it already opens in the browser and shows the translated text.
Reply
#5
Thanks for the information Guyz !!!!
Reply
#6
Thanks for this.. I wonder if it will work if I change the link to bing, I feel it is a bit more accurate in translating.


credit repair wilmington
Reply
#7
(04-17-2022, 09:17 AM)rsikes18 Wrote: Thanks for this.. I wonder if it will work if I change the link to bing, I feel it is a bit more accurate in translating.


credit repair wilmington

Bing's URL doesn't seem to take into consideration the input and output language like Google Translate does. You will need to modify the code a little bit for it to work with Bing.
Reply
#8
Thank you for sharing the script, it saved a lot of time and it is easier this way.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)