Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DeepL Translator (close #203) #204

Merged
merged 1 commit into from
Dec 12, 2017
Merged

Add DeepL Translator (close #203) #204

merged 1 commit into from
Dec 12, 2017

Conversation

soimort
Copy link
Owner

@soimort soimort commented Dec 12, 2017

Due to recurring requests (#203, #121, and some email buried in the snow).

Usage:

  1. (One-time) Call trans with option -e deepl.
  2. (Permanent) Add :engine "deepl" to the configuration file.

Example:

$ trans :en 'mi casa es su casa' -e deepl
mi casa es su casa

my home is your home

[ Español → English ]

    My house is your house.
    My home is your home.
    my house is your house

@tflo
Copy link

tflo commented Dec 16, 2017

There seems to be an encoding problem with DeepL (at least on my Mac). It returns non-ASCII characters with their Unicode code point. Example:

$ trans -b -e deepl :de+fr+es 'Listen to me!'
H\u00f6r mir zu!
\u00c9coute-moi bien!
\u00a1Esc\u00fachame!

The replaced characters here are ö, É, ¡ and ú.

This is only with the deepl engine. google, bing and yandex are fine.

– Tom

@soimort
Copy link
Owner Author

soimort commented Dec 16, 2017

@tflo
This is an existing issue on macOS / *BSD, since non-GNU systems do not have anything equivalent to GNU printf that properly prints Unicode-escaped string to stdout.

@tflo
Copy link

tflo commented Dec 16, 2017

Thanks for the info. Will try to find a workaround…

– Tom

@tflo
Copy link

tflo commented Dec 16, 2017

@soimort

Well, here an – ugly – workaround, with a bit of Perl to convert the characters:

$ trans -b -e deepl :de+fr+es 'Listen to me!' | perl -Mopen=':std',':encoding(UTF-8)' -pe '$_ =~ s/\\u(.{4})/chr(hex($1))/eg;'
Hör mir zu!
Écoute-moi bien!
¡Escúchame!

Tested only on a few samples.

– Tom

@soimort
Copy link
Owner Author

soimort commented Dec 16, 2017

Should be fixed by 4536adc using bash.

@vmeade
Copy link

vmeade commented Dec 22, 2017

Preface: Sorry I am noob.

I 'git pull' in my local 'translate-shell' directory for the newest files (to include DeepL) however in the command line "trans -S" deepl is not found. Could you steer me in a direction to solving this problem?

@soimort
Copy link
Owner Author

soimort commented Dec 22, 2017

@vmeade Please check your version. Updated one should be 0.9.6.6.

$ trans -V          
Translate Shell       0.9.6.6

platform              Linux
gawk (GNU Awk)        4.2.0
fribidi (GNU FriBidi) 0.19.7
audio player          mplayer
terminal pager        less
terminal type         xterm
user locale           en_US.UTF-8 (English)
home language         en
source language       auto
target language       en
translation engine    google
proxy                 [NONE]
user-agent            Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/602.1 (KHTML, like Gecko) Version/8.0 Safari/602.1 Epiphany/3.18.2
theme                 happiness.trans
init file             /home/soimort/.translate-shell/init.trans

Report bugs to:       https://github.com/soimort/translate-shell/issues

@tflo
Copy link

tflo commented Jan 4, 2018

Should be fixed by 4536adc using bash.

Isn’t this committed yet?

With DeepL and 0.9.6.6 I still get the hex code points in the output when I remove my perl after-treatment. The same with 0.9.6.6-git:c8107fe (installed via Homebrew --HEAD).

@waxfingers
Copy link

Seems broken again in 0.9.6.7 (via homebrew)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants