3

How to add online dictionaries feature (mainly google translator) for GoldenDict

Right now a discussed solution is in html with an iframe

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Iframe test for GoldenDict</title>
   </head>
    Google translate:
  <iframe src="https://translate.google.cn/#auto/zh-CN/hello"></iframe>
  <br>
</html> 

Is there a simple translation script/app that read a sting variable in and return it translated ?

3

Translate-shell

Translate-shell use different online translation services... we could integrate the whole application or some of it's source to provide translation to goldendict.

https://github.com/soimort/translate-shell

Quick Solution Using Translate-Shell

GoldenDict have a Programs feature in the dictionary settings section so an easy way to add an online translation feature would be to use one of those two command line tools translate-shell or the python script doodle-translate

As an example of French/English translation with google under Program section we would just add

trans -e google -s en -t fr -show-original y -show-original-phonetics n -show-translation y -no-ansi -show-translation-phonetics n -show-prompt-message n -show-languages y -show-original-dictionary n -show-dictionary n -show-alternatives n "%GDWORD%"

and

trans -e google -s fr -t en -show-original y -show-original-phonetics n -show-translation y -no-ansi -show-translation-phonetics n -show-prompt-message n -show-languages y -show-original-dictionary n -show-dictionary n -show-alternatives n "%GDWORD%"

Microsoft Windows Alternative

For windows the same solution could be used but with python + translate or may be cygwin + translate-shell

Here is a capture

enter image description here

enter image description here

  • Can we make it work on Windows ? – ITFan May 23 at 7:38
  • @ITFan i updated the answer, for windows the same solution could be used but with python + translate or may be cygwin + translate-shell – intika May 23 at 7:49
  • @ intika pypi.org/project/translate uses Microsoft Translation API not Google translate. I've compared the results and found it's slower and worse comparing to Google translate. – ITFan May 23 at 13:42
  • then may be the cygwin solution (i did not test it tho) or gnuwin32.sourceforge.net – intika May 23 at 13:51
  • I followed this thread softwarerecs.stackexchange.com/questions/11919/… but then got these errors when run "sh trans" in cmd.exe /usr/bin/trans: trans: line 5630: syntax error near unexpected token (' /usr/bin/trans: trans: line 5630: gawk -f <(echo -E "$TRANS_PROGRAM") - "$@"' Do you have any idea ? – ITFan May 23 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.