Skip to content

Instantly share code, notes, and snippets.

@wyhasany
Last active April 19, 2024 13:08
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wyhasany/d89490272d6a1a5b2cb64b1e6a2d3bf7 to your computer and use it in GitHub Desktop.
Save wyhasany/d89490272d6a1a5b2cb64b1e6a2d3bf7 to your computer and use it in GitHub Desktop.
Wine configuration for QTranslate under Linux/MacOS

QTranslate for Linux

This is tutorial how to run awesome application to context translation: QTranslate The authors write on the site that they don't plan to support QTranslate for other platforms than Microsoft Windows. I felt a lack similiar solution at Linux. So I've tried to run that application at Linux Ubuntu distribution. On the end that's works I really appreciate all the help which I received at winehq forum.

Installation

Below you have instructions how to run QTranslate on your own machine:

  1. Install newest wine + wine staging following:

webupd8

  1. Install packages for clipboard copying:
sudo apt-get install xclip xsel
#install newest winetricks:
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks 
sudo cp winetricks /usr/local/bin
  1. Clone this gist repository:
git clone https://gist.github.com/d89490272d6a1a5b2cb64b1e6a2d3bf7.git
  1. Run installer (cancel installing mono, .NET and gecko):
cd d89490272d6a1a5b2cb64b1e6a2d3bf7
chmod +x install_qtranslate.sh
./install_qtranslate.sh
  1. Update shortcuts binding at QTranslate application:

QTranslate should appear at your tray (near the clock). If not run QTranslate from your start menu. Then click right mouse on icon of QTranslate, then choose Options menu item.

At Basics tab choose Font name: Calibri and Text size: 11. Because default font doesn't support a lot of signs (i.e. some French accents, cyrillic letters etc.). Set here your First language. The go to next tab.

At Hotkeys tab clear hotkeys Control+Q and Control+Shift+Q then apply changes. After that asign new shortcuts Translate clipboard in popup window to Control+Q and Dictionary from clipboard as Control+Shift+Q.

At Advanced tab set Default browser as Mozilla Firefox.

You have properly configured QTranslate now.

  1. Configure global shortcuts at your system

Using your GUI, find application responsible for your system global shortcuts. Run it, and append new custom shortcuts to the scripts (use shortcuts comfortable to you and remember to don't override system shortcuts, or change them before asign them to this scripts):

  • ~/bin/send_wine_ctrl_q.sh for translation selected text in popup
  • ~/bin/send_wine_ctrl_shift_q.sh for see selected word in popup dictionary
  • ~/bin/send_wine_ctrl_e.sh for listening pronunciation of selected word - works well only in wine context

If you would like to autostart the QTranslate then point ~/bin/qtranslate_wrapper.sh ay your GUI autostart.

  1. Optionally you can clean gist files:
cd ..
rm -R d89490272d6a1a5b2cb64b1e6a2d3bf7
  1. You can polish overlooking of app with Wine Config:

Run WINEPREFIX=~/qtranslate_32 winecfg. Then on Graphics tab check Automatically capture the mouse in Full-screen windows and set proper dpi for your monitor. At Staging tab selest all chechboxes except: Enable Environmental Audio Extensions (EAX)

Voila! It should works for you now!

If you would like to contribute to that Gist please tell me about that in comment.

Uninstallation

Run WINEPREFIX=~/qtranslate_32 winetricks then choose Select the default wineprefix and press OK. Make sure that proper prefix is showned at title bar. You have to choose Delete ALL APPLICATIONS INSIDE THIS WINEPREFIX press OK and accept all dialogs.

Known issues:

In dictionary popup the IPA is not showing properly.

#!/bin/bash
cd ~/
export WINEPREFIX="${PWD}/qtranslate_32"
export WINEARCH=win32
wineboot -u
winetricks sandbox
winetricks winxp
winetricks ie8 riched20
winetricks allfonts
cd qtranslate_32/drive_c
wget https://ftp.mozilla.org/pub/firefox/releases/10.0.1/win32/en-US/Firefox%20Setup%2010.0.1.exe
wine Firefox\ Setup\ 10.0.1.exe &
wget https://qtranslate1.appspot.com/QTranslate.6.3.1.exe
wine QTranslate.6.3.1.exe &
cd Program\ Files/
wget https://ahkscript.org/download/ahk.zip --no-check-certificate
mkdir AutoHotKey
unzip ahk.zip -d AutoHotKey
rm ahk.zip
#Set in QTranslate hotkeys (Options -> Hotkey tab):
#ctrl+q -> Translate clipboard in popup window
#ctrl+shift+q -> Dictionary from clipboard
#Set Mozilla Firefox at tab Advanced: default browser option
git clone https://gist.github.com/d89490272d6a1a5b2cb64b1e6a2d3bf7.git
cd d89490272d6a1a5b2cb64b1e6a2d3bf7/
mkdir ~/bin
chmod +x send_wine*
chmod +x qtranslate_wrapper.sh
rm ~/bin/send_wine*
rm ~/bin/qtranslate_wrapper.sh
cp qtranslate_wrapper.sh ~/bin
cp send_wine* ~/bin
rm ~/qtranslate_32/drive_c/Program\ Files/AutoHotKey/SendInput*
cp *.ahk ~/qtranslate_32/drive_c/Program\ Files/AutoHotKey/
cd ..
rm -Rf d89490272d6a1a5b2cb64b1e6a2d3bf7
#set system shortcuts to script files: ~/bin/SendInput*
#!/bin/bash
WINEPREFIX="${HOME}/qtranslate_32" wine ~/qtranslate_32/drive_c/Program\ Files/QTranslate/QTranslate.exe
#!/bin/bash
#xsel
WINDOW="$(xdotool getactivewindow)"
#xdotool key --delay 0 --window "${WINDOW}" ctrl+c
#notify-send --icon=info "$(xsel --clipboard)"
cd ~/bin
xsel > temp
cat temp | xclip -sel clip
cd ~/qtranslate_32/drive_c/Program\ Files/AutoHotKey/
WINEPREFIX=~/qtranslate_32 wine AutoHotkeyU32.exe SendInputCtrlE.ahk
cd ~/bin
rm temp
#!/bin/bash
#xsel
WINDOW="$(xdotool getactivewindow)"
#xdotool key --delay 0 --window "${WINDOW}" ctrl+c
cd ~/bin
xsel > temp
#xsel --clipboard < temp
cat temp | xclip -sel clip
#notify-send --icon=info "$(xsel --clipboard)"
cd ~/qtranslate_32/drive_c/Program\ Files/AutoHotKey/
WINEPREFIX=~/qtranslate_32 wine AutoHotkeyU32.exe SendInputCtrlQ.ahk
cd ~/bin
rm temp
#!/bin/bash
#xsel
WINDOW="$(xdotool getactivewindow)"
#xdotool key --delay 0 --window "${WINDOW}" ctrl+c
#notify-send --icon=info "$(xsel --clipboard)"
cd ~/bin
xsel > temp
cat temp | xclip -sel clip
cd ~/qtranslate_32/drive_c/Program\ Files/AutoHotKey/
WINEPREFIX=~/qtranslate_32 wine AutoHotkeyU32.exe SendInputCtrlShiftQ.ahk
cd ~/bin
rm temp
;Clipboard:=%1%
SendInput ^e
Return
;Clipboard:=%1%
SendInput ^q
Return
;Clipboard:=%1%
SendInput ^+q
Return
@Titan7777
Copy link

Please provide a link to the manual to run version 6.7.1. Since I do not imagine work without Qtranslate

@vladimirlv17
Copy link

Hello All !
Thank you very match Michał.
The new version of the program Qtranslate requires improvements in the installation file.
As user B27 correctly noted Qtranslate updated: RichEdit control from RichEdit20W to RichEdit50W.
In order to run them, you need to install msftedit (Microsoft RichEdit Control) in winerticks
What needs to be fixed in the file install_qtranslate.sh.

or win7

line 7. winxp

instead riched20

line 8. winetricks ie8 msftedit

current version Qtranslate

line 13. wget https://qtranslate1.appspot.com/QTranslate.6.7.1.exe
line 14. wine QTranslate.6.7.1.exe &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment