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

Trying to translate a full Web page just hangs #295

Closed
forthrin opened this issue Apr 17, 2019 · 6 comments
Closed

Trying to translate a full Web page just hangs #295

forthrin opened this issue Apr 17, 2019 · 6 comments

Comments

@forthrin
Copy link

forthrin commented Apr 17, 2019

Is translating a full Web page supported? I can't really tell from the man pages or the help, but there was at least one bug report that referenced this. Anyway, trying to do this just hangs forever.

trans :fr http://www.w3.org/
@soimort
Copy link
Owner

soimort commented Apr 17, 2019

Please follow https://github.com/soimort/translate-shell/blob/develop/CONTRIBUTING.md and report the information of trans -V.

@forthrin
Copy link
Author

$ trans -V :fr http://www.w3.org/
gawk: /dev/fd/63:177: warning: regexp escape sequence `\"' is not a known regexp operator
Translate Shell       0.9.6.9

platform              Darwin
gawk (GNU Awk)        5.0.0
fribidi (GNU FriBidi) 1.0.5
audio player          mpg123
terminal pager        less
terminal type         xterm-256color
user locale           en_US.UTF-8 (English)
home language         en
source language       auto
target language       fr
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                 default
init file             [NONE]

@soimort
Copy link
Owner

soimort commented Apr 17, 2019

On macOS, what trans actually does is simply invoking

$ open 'https://translate.google.com/translate?hl=en&sl=auto&tl=fr&u=http://www.w3.org/'

If the above doesn't work, try specifying an existing browser,

$ trans -browser firefox :fr http://www.w3.org/

@forthrin
Copy link
Author

Aha! Well, it seems trans looks up the BROWSER environment variable, which is set to a special handler on my system. Unsetting this makes the browser launch as expected. So consider this "user error" :)

However, I was sort of wondering/expecting if trans would print a text-only version of the translated Web page to the terminal.

I see now that the whole thing is written in Bash, and creating a text-only version would at require at least a minimum of semi-intelligent HTML parsing and extraction, and quite often an imperfect result.

So unless some of the translation engines support text-only output themselves, or if there is a huge interest in this, this request is maybe out of scope?

@soimort
Copy link
Owner

soimort commented Apr 17, 2019

Given that there is no universally accepted, easy way of transforming an HTML page into plain text, I'd say this feature is out of scope. Not to mention a lot of modern websites that make heavy use of JavaScript in their front-ends!

A reasonable solution would be using a terminal-based web browser such as w3m or lynx. Unfortunately, these browsers seem to be undermaintained these days (compared to the fast-developing Chrome, WebKit, and Firefox), and none of them supports Google Translate's frame embedding for website translation.

For me, I'm not a big command-line junkie trying to view everything text-only. So if it's a web page designed for displaying in a web browser, I see little reason to restrict oneself to a text-only terminal. I'm not going to have any time / interest to maintain such a nontrivial feature that I myself barely need to use.

@forthrin
Copy link
Author

forthrin commented Apr 18, 2019

If I get the inspiration I may have a go. If so, I'll let you know.

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

No branches or pull requests

2 participants