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
@XandrMaster
Copy link

XandrMaster commented Sep 28, 2018

This is the wine error report:
Unhandled exception: page fault on read access to 0x000000d8 in 32-bit code (0x7cb9590f).
Register dump:
CS:0023 SS:002b DS:002b ES:002b FS:0063 GS:006b
EIP:7cb9590f ESP:009cfd90 EBP:009cfda8 EFLAGS:00010246( R- -- I Z- -P- )
EAX:00000000 EBX:7cbe3000 ECX:009cfdbc EDX:7cbe1ee0
ESI:009cfe0c EDI:00160d28
Stack dump:
0x009cfd90: 00169a2c 7cb958e6 009cfdbc 009cfe00
0x009cfda0: 009cfe04 009cfe08 009cfde8 0043e558
0x009cfdb0: 0043e539 00556430 0043e558 00160d28
0x009cfdc0: 00000000 009cfe0c 009cfe04 001587a8
0x009cfdd0: 0043b9bf 0057c178 00000000 00000001
0x009cfde0: 009cfe00 009cfe04 009cfe68 0045cea6
Backtrace:
=>0 0x7cb9590f in jscript (+0x4590f) (0x009cfda8)
1 0x0043e558 in qtranslate (+0x3e557) (0x009cfde8)
2 0x0045cea6 in qtranslate (+0x5cea5) (0x009cfe68)
3 0x0045d530 in qtranslate (+0x5d52f) (0x009cfeb0)
4 0x0043afdb in qtranslate (+0x3afda) (0x009cfec4)
5 0x0043af24 in qtranslate (+0x3af23) (0x009cfedc)
6 0x7bc7ddd8 call_thread_func_wrapper+0xb() in ntdll (0x009cfeec)
7 0x7bc81c09 in ntdll (+0x71c08) (0x009cffdc)
8 0x7bc7ddca call_thread_exit_func+0x31() in ntdll (0x009cffec)
0x7cb9590f: movl 0xd8(%eax),%eax
Modules:
Module Address Debug info Name (129 modules)
PE 400000- 5a0000 Export qtranslate
PE 10000000-10050000 Deferred bass
ELF 7ac00000-7ac84000 Deferred riched20
-PE 7ac10000-7ac84000 \ riched20
ELF 7b400000-7b7e9000 Deferred kernel32
-PE 7b410000-7b7e9000 \ kernel32
ELF 7bc00000-7bcf9000 Dwarf ntdll
-PE 7bc10000-7bcf9000 \ ntdll
ELF 7c000000-7c004000 Deferred
ELF 7cb4a000-7cc00000 Dwarf jscript
-PE 7cb50000-7cc00000 \ jscript
ELF 7cdae000-7cdf4000 Deferred usp10
-PE 7cdb0000-7cdf4000 \ usp10
ELF 7cdf4000-7ce0e000 Deferred msftedit
-PE 7ce00000-7ce0e000 \ msftedit
PE 7ce54000-7ce68000 Deferred api-ms-win-core-localization-l1-
PE 7ce60000-7ce68000 Deferred api-ms-win-core-localization-l1-C:\windows\system32\api-ms-win-core-localization-l1-2-1.dll
ELF 7ce68000-7ce7c000 Deferred api-ms-win-core-fibers-l1-1-1<el
PE 7ce70000-7ce7c000 Deferred api-ms-win-core-fibers-l1-1-1
ELF 7ce7c000-7ce94000 Deferred libgpg-error.so.0
ELF 7ce94000-7cf75000 Deferred libgcrypt.so.20
ELF 7cf75000-7cf8b000 Deferred liblz4.so.1
ELF 7cf8b000-7cfb7000 Deferred liblzma.so.5
ELF 7cfb7000-7d047000 Deferred libsystemd.so.0
ELF 7d047000-7d050000 Deferred libffi.so.6
ELF 7d050000-7d068000 Deferred libresolv.so.2
ELF 7d068000-7d0c3000 Deferred libdbus-1.so.3
ELF 7d0c3000-7d14e000 Deferred libgmp.so.10
ELF 7d14e000-7d184000 Deferred libhogweed.so.4
ELF 7d184000-7d1c0000 Deferred libnettle.so.6
ELF 7d1c0000-7d1d5000 Deferred libtasn1.so.6
ELF 7d1d5000-7d356000 Deferred libunistring.so.2
ELF 7d356000-7d374000 Deferred libidn2.so.0
ELF 7d374000-7d4c2000 Deferred libp11-kit.so.0
ELF 7d4c2000-7d4cf000 Deferred libkrb5support.so.0
ELF 7d4cf000-7d504000 Deferred libk5crypto.so.3
ELF 7d504000-7d5e0000 Deferred libkrb5.so.3
ELF 7d5e0000-7d5f4000 Deferred libavahi-client.so.3
ELF 7d5f4000-7d78a000 Deferred libgnutls.so.30
ELF 7d78a000-7d7de000 Deferred libgssapi_krb5.so.2
ELF 7d7de000-7d870000 Deferred libcups.so.2
ELF 7d878000-7d88c000 Deferred api-ms-win-core-synch-l1-2-0<elf
PE 7d880000-7d88c000 Deferred api-ms-win-core-synch-l1-2-0
ELF 7d88c000-7d8c4000 Deferred uxtheme
-PE 7d890000-7d8c4000 \ uxtheme
ELF 7d8c4000-7d8cb000 Deferred libxfixes.so.3
ELF 7d8cb000-7d8d7000 Deferred libxcursor.so.1
ELF 7d8d7000-7d8ea000 Deferred libxi.so.6
ELF 7d8ea000-7d8ee000 Deferred libxcomposite.so.1
ELF 7d8ee000-7d8fb000 Deferred libxrandr.so.2
ELF 7d8fb000-7d907000 Deferred libxrender.so.1
ELF 7d907000-7d90e000 Deferred libxxf86vm.so.1
ELF 7d90e000-7d912000 Deferred libxinerama.so.1
ELF 7d912000-7d91c000 Deferred librt.so.1
ELF 7d91c000-7d937000 Deferred libbsd.so.0
ELF 7d937000-7d93e000 Deferred libxdmcp.so.6
ELF 7d93e000-7d942000 Deferred libxau.so.6
ELF 7d942000-7d96e000 Deferred libxcb.so.1
ELF 7d96e000-7dab8000 Deferred libx11.so.6
ELF 7dab8000-7dacd000 Deferred libxext.so.6
ELF 7dacf000-7dad4000 Deferred libkeyutils.so.1
ELF 7dad4000-7dad9000 Deferred libcom_err.so.2
ELF 7dad9000-7dae7000 Deferred libavahi-common.so.3
ELF 7dae9000-7db76000 Deferred winex11
-PE 7daf0000-7db76000 \ winex11
ELF 7db76000-7db9a000 Deferred imm32
-PE 7db80000-7db9a000 \ imm32
ELF 7dbf7000-7dc29000 Deferred libexpat.so.1
ELF 7dc29000-7dc74000 Deferred libfontconfig.so.1
ELF 7dc74000-7dc93000 Deferred libz.so.1
ELF 7dc93000-7dccd000 Deferred libpng16.so.16
ELF 7dccd000-7dd8a000 Deferred libfreetype.so.6
ELF 7dda6000-7dde0000 Deferred ws2_32
-PE 7ddb0000-7dde0000 \ ws2_32
ELF 7dde0000-7de96000 Deferred msvcrt
-PE 7de00000-7de96000 \ msvcrt
ELF 7de96000-7df4f000 Deferred winmm
-PE 7dea0000-7df4f000 \ winmm
ELF 7df4f000-7df7a000 Deferred msacm32
-PE 7df50000-7df7a000 \ msacm32
ELF 7df7a000-7dfba000 Deferred winspool
-PE 7df80000-7dfba000 \ winspool
ELF 7dfba000-7e0a5000 Deferred comdlg32
-PE 7dfc0000-7e0a5000 \ comdlg32
ELF 7e0a5000-7e139000 Deferred gdiplus
-PE 7e0b0000-7e139000 \ gdiplus
ELF 7e139000-7e256000 Deferred comctl32
-PE 7e140000-7e256000 \ comctl32
ELF 7e256000-7e26a000 Deferred msimg32
-PE 7e260000-7e26a000 \ msimg32
ELF 7e26a000-7e27e000 Deferred sensapi
-PE 7e270000-7e27e000 \ sensapi
ELF 7e27e000-7e29c000 Deferred jsproxy
-PE 7e280000-7e29c000 \ jsproxy
ELF 7e29c000-7e2d9000 Deferred winhttp
-PE 7e2a0000-7e2d9000 \ winhttp
ELF 7e2d9000-7e336000 Deferred oleacc
-PE 7e2e0000-7e336000 \ oleacc
ELF 7e336000-7e34a000 Deferred psapi
-PE 7e340000-7e34a000 \ psapi
ELF 7e34a000-7e47c000 Deferred oleaut32
-PE 7e360000-7e47c000 \ oleaut32
ELF 7e47c000-7e4f2000 Deferred shlwapi
-PE 7e490000-7e4f2000 \ shlwapi
ELF 7e4f2000-7e744000 Deferred shell32
-PE 7e500000-7e744000 \ shell32
ELF 7e744000-7e7c5000 Deferred rpcrt4
-PE 7e750000-7e7c5000 \ rpcrt4
ELF 7e7c5000-7e91f000 Deferred ole32
-PE 7e7e0000-7e91f000 \ ole32
ELF 7e91f000-7e997000 Deferred advapi32
-PE 7e930000-7e997000 \ advapi32
ELF 7e997000-7eac5000 Deferred gdi32
-PE 7e9a0000-7eac5000 \ gdi32
ELF 7eac5000-7eca5000 Deferred user32
-PE 7eae0000-7eca5000 \ user32
ELF 7eca5000-7ecb9000 Deferred libnss_files.so.2
ELF 7ecb9000-7ecd4000 Deferred libnsl.so.1
ELF 7ecd4000-7ece2000 Deferred libnss_nis.so.2
ELF 7eee2000-7efe4000 Deferred libm.so.6
ELF 7efe6000-7f000000 Deferred version
-PE 7eff0000-7f000000 \ version
ELF f7bc6000-f7bcb000 Deferred libdl.so.2
ELF f7bcb000-f7da7000 Deferred libc.so.6
ELF f7da7000-f7dc6000 Deferred libpthread.so.0
ELF f7dc6000-f7dd0000 Deferred libnss_compat.so.2
ELF f7de2000-f7f98000 Dwarf libwine.so.1
ELF f7f9a000-f7fc2000 Deferred ld-linux.so.2
ELF f7fc5000-f7fc7000 Deferred [vdso].so
Threads:
process tid prio (all id:s are in hex)
0000000e services.exe
00000022 0
0000001d 0
00000013 0
00000010 0
0000000f 0
00000011 winedevice.exe
0000001a 0
00000017 0
00000016 0
00000012 0
0000001b plugplay.exe
0000001f 0
0000001e 0
0000001c 0
00000020 winedevice.exe
00000029 0
00000024 0
00000023 0
00000021 0
00000035 (D) Z:\home\xandr\temp\001\QTranslate.6.7.1\QTranslate.exe
0000003c 0 <==
00000036 0
00000037 explorer.exe
0000003b 0
0000003a 0
00000039 0
00000038 0
System information:
Wine build: wine-3.0.3
Platform: i386 (WOW64)
Version: Windows 10
Host system: Linux
Host version: 4.15.0-34-generic

@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