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


Messages In This Thread
Keyboard Shortcut - Launch Google Translate for Selected Text - by pilot888 - 10-17-2019, 06:59 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)