SDL Trados Studio
SDL Trados GroupShare
SDL Trados Business Manager
SDL Trados Live
SDL MultiTerm
SDL Passolo
SDL Speech to Text
SDL Managed Translation - Enterprise
SDL MultiTrans
SDL TMS
SDL WorldServer
Translation Management Connectors
SDL LiveContent S1000D
SDL Contenta S1000D
SDL XPP
SDL Tridion Docs
SDL Tridion Sites
SDL Content Assistant
SDL Machine Translation Cloud
SDL Machine Translation Connectors
SDL Machine Translation Edge
Language Developers
Tridion Developers
Tridion Docs Developers
Xopus Developers
Community Help
SDL User Experience
Language Products - GCS Internal Community
SDL Community Internal Group
SDL Access Customer Portal
SDL Professional Services
SDL Training & Certification
Style Guides
Language Technology Partner Group
SDL Academic Partners
SDL Approved Trainers
SDL Enterprise Technology Partners
XyUser Group
ETUG (European Trados User Group) Public Information
Machine Translation User Group
Nordic SDL Tridion Docs User Group
SDL Tridion UK Meetup
SDL Tridion User Group New England
SDL Tridion West Coast User Group
SDL WorldServer User Group
Tridion Docs Europe & APAC User Group
Tridion User Group Benelux
Tridion User Group Ohio Valley
SDL MultiTerm Ideas
SDL Passolo Ideas
SDL Trados GroupShare Ideas
SDL Trados Studio Ideas
SDL Machine Translation Cloud Ideas
SDL Machine Translation Edge Ideas
SDL Language Cloud TMS Ideas
SDL Language Cloud Terminology Ideas
SDL Language Cloud Online Editor Ideas
SDL Managed Translation - Enterprise Ideas
SDL TMS Ideas
SDL WorldServer Ideas
SDL Tridion Docs Ideas
SDL Tridion Sites Ideas
SDL LiveContent S1000D Ideas
SDL XPP Ideas
Events & Webinars
To SDL Documentation
To SDL Support
What's New in SDL
Detecting language please wait for.......
This script works everywhere you can select text: Trados Studio, MS Office, webpages, PDF files... you name it.
When you first run the script, you can set your source language (either auto if you want Google to recognize the language or a two letter language code) and target language. There are some predefined languages I used most, but one can directly write in the edit boxes. Alternatively, you can modify the code and add the languages you use most. Adding a double pipe character "||" after a language makes it the one selected by default. You can call up the language selection interface by pressing [Ctrl]+[F12].
Just select the text you want to have translate by Google Translate (maybe not an entire page, since it will be not too readable) and press [F12]. Ah tool tip shows Google is busy translating and then you get the translation in a tooltip next to the caret position:
↓
To make the tooltip with the translation disappear, just press [F12] again.
Text in green are comments in the code for better understanding. The code can be pasted like this in an editor.
#NoEnv ;~ Recommended for performance and compatibility with future AutoHotkey releases.SendMode Input ;~ Recommended for new scripts due to its superior speed and reliability.SetWorkingDir %A_ScriptDir% ;~ Ensures a consistent starting directory.SetTitleMatchMode, 3ToolTipVisible = 0;~ Interface for selecting source and target languageGui, 1:Add, Text, x10 y15 vTb1, Source language:Gui, 1:Add, Combobox, x+20 yp-3 vLangIn, auto||en|de|fr|it|es|nl|ja|sk|tr|hu ;~ place double pipe behind language to be used as defaultGui, 1:Add, Text, x10 y+15 vTb2, Target language:Gui, 1:Add, Combobox, x+22 yp-3 vLangOut, en|de||fr|it|es|nl|ja|sk|tr|hu ;~ place double pipe behind language to be used as defaultGui, 1:Add, Checkbox, x10 y+20 Checked vPaste2CB, Paste translation to clipoard when closing tooltipGui, 1:Add, Checkbox, x10 y+15 Checked vHideToolTip, Hide tooltip on mouseclickGui, 1:Add, Button, x30 y+20 w80 vB1, &ExitGui, 1:Add, Button, x+30 w80 Default vB2, &OKGui, 1:Show, AutosizeReturnButtonExit:GuiEscape:GuiClose:ExitAppButtonOK:Gui, 1:SubmitReturn;~ [Ctrl]+[F12] shows the little user interface for changing source and target language^F12::Gui, 1:Show, AutosizeReturn;~ A mouse click makes the tooltip disappear~RButton::~MButton::~LButton::If HideToolTip = 0 ReturnIf ToolTipVisible = 1{ ToolTip ToolTipVisible = 0 Return}Return;~ [F12] runs Google Translate for selected text or makes the tooltip with the translation disappear if it is visibleF12::If ToolTipVisible = 1{ ToolTip ToolTipVisible = 0 Return}CurrentCB = %Clipboard%Clipboard =SendInput, ^cClipWait, 5If ErrorLevel{ MsgBox, 48, GoogleTranslateSelection, No text highlighted or problem copying text to clipboard. Return}Source = %Clipboard%StringLen, SourceLength, SourceSourceLength := SourceLength * 5ToolTip, Translating... please wait ☺., % A_CaretX-SourceLength, % A_CaretY+50Target =Target := GoogleTranslate(Source,LangIn,LangOut)ToolTip, %Target%, % A_CaretX-SourceLength, % A_CaretY+50ToolTipVisible = 1If Paste2CB = 1 Clipboard = %Target%Else Clipboard = %CurrentCB%ReturnGoogleTranslate(Source,LangIn,LangOut){ StringReplace, Source, Source, %A_Space%, `%20, All Base := "translate.google.com/#" Path := Base . LangIn . "/" . LangOut . "/" . Source IE := ComObjCreate("InternetExplorer.Application") ;~ Creation of hidden Internet Explorer instance to look up Google Translate and retrieve translation IE.Navigate(Path) While IE.readyState!=4 || IE.document.readyState!="complete" || IE.busy Sleep 50 Result := IE.document.all.result_box.innertext IE.Quit Return Result}
#NoEnv ;~ Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ;~ Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ;~ Ensures a consistent starting directory.
SetTitleMatchMode, 3
ToolTipVisible = 0
;~ Interface for selecting source and target language
Gui, 1:Add, Text, x10 y15 vTb1, Source language:
Gui, 1:Add, Combobox, x+20 yp-3 vLangIn, auto||en|de|fr|it|es|nl|ja|sk|tr|hu ;~ place double pipe behind language to be used as default
Gui, 1:Add, Text, x10 y+15 vTb2, Target language:
Gui, 1:Add, Combobox, x+22 yp-3 vLangOut, en|de||fr|it|es|nl|ja|sk|tr|hu ;~ place double pipe behind language to be used as default
Gui, 1:Add, Checkbox, x10 y+20 Checked vPaste2CB, Paste translation to clipoard when closing tooltip
Gui, 1:Add, Checkbox, x10 y+15 Checked vHideToolTip, Hide tooltip on mouseclick
Gui, 1:Add, Button, x30 y+20 w80 vB1, &Exit
Gui, 1:Add, Button, x+30 w80 Default vB2, &OK
Gui, 1:Show, Autosize
Return
ButtonExit:
GuiEscape:
GuiClose:
ExitApp
ButtonOK:
Gui, 1:Submit
;~ [Ctrl]+[F12] shows the little user interface for changing source and target language
^F12::
;~ A mouse click makes the tooltip disappear
~RButton::
~MButton::
~LButton::
If HideToolTip = 0
If ToolTipVisible = 1
{
ToolTip
}
;~ [F12] runs Google Translate for selected text or makes the tooltip with the translation disappear if it is visible
F12::
CurrentCB = %Clipboard%
Clipboard =
SendInput, ^c
ClipWait, 5
If ErrorLevel
MsgBox, 48, GoogleTranslateSelection, No text highlighted or problem copying text to clipboard.
Source = %Clipboard%
StringLen, SourceLength, Source
SourceLength := SourceLength * 5
ToolTip, Translating... please wait ☺., % A_CaretX-SourceLength, % A_CaretY+50
Target =
Target := GoogleTranslate(Source,LangIn,LangOut)
ToolTip, %Target%, % A_CaretX-SourceLength, % A_CaretY+50
ToolTipVisible = 1
If Paste2CB = 1
Clipboard = %Target%
Else
Clipboard = %CurrentCB%
GoogleTranslate(Source,LangIn,LangOut)
StringReplace, Source, Source, %A_Space%, `%20, All
Base := "translate.google.com/#"
Path := Base . LangIn . "/" . LangOut . "/" . Source
IE := ComObjCreate("InternetExplorer.Application") ;~ Creation of hidden Internet Explorer instance to look up Google Translate and retrieve translation
IE.Navigate(Path)
While IE.readyState!=4 || IE.document.readyState!="complete" || IE.busy
Sleep 50
Result := IE.document.all.result_box.innertext
IE.Quit
Return Result
If you have suggestions or ideas on how to improve this script, please don't hesitate to let me know!
Edit 1:
Edit 2: