soimort / translate-shell

:speech_balloon: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc.
https://www.soimort.org/translate-shell
The Unlicense
6.94k stars 391 forks source link

Adaptation for windows #333

Open elig0n opened 4 years ago

elig0n commented 4 years ago

Since 'awk' 'curl' and other requirements are readily available in PE-executable form for Windows systems, can translate-shell be adapted for a windows version using batch/powershell instead of bash ?

filtermap commented 4 years ago

I'm not sure how to replace requirements with PE files. But Docker is available for the way to use translate-shell on Windows. For a instance, this project is executable on Cmd/PowerShell.

filtermap/docker-compose-trans https://github.com/filtermap/docker-compose-trans

soimort commented 4 years ago

Isn't bash just as well available on Windows 10 then? What's the point of solely removing the dependency on bash while it still has to rely on Unix-style tools like awk and curl?

elig0n commented 4 years ago

Isn't bash just as well available on Windows 10 then? What's the point of solely removing the dependency on bash while it still has to rely on Unix-style tools like awk and curl?

If I'm not mistaken bash only comes with and run under wsl/cygwin/etc and has a lot ofbdependencies so it's not as compact as the other utilities. And then running it from native cmd has its uses.

elig0n commented 4 years ago

I'm not sure how to replace requirements with PE files. But Docker is available for the way to use translate-shell on Windows. For a instance, this project is executable on Cmd/PowerShell.

filtermap/docker-compose-trans https://github.com/filtermap/docker-compose-trans

if the requirements are on the PATH they can be simply called as they are.

soimort commented 4 years ago

If you have gawk in PATH, you may clone the repository here and invoke it without bash at all:

> gawk -f translate.awk -- Bonjour

However, I believe this won't work on Windows native cmd if you don't run on a proper POSIX layer (Cygwin, MinGW, WSL). translate-shell was not designed for non-POSIX platforms from the very beginning: It assumes common *nix utilities such as POSIX-style echo and hexdump; you'll need to have those compiled as PE-executables too. Furthermore, things like ANSI escaped colors, will be completely messed up on a Windows console.

I'm not likely to spend time on fixing all those issues for non-POSIX systems. It makes a lot of sense for Windows users to just use WSL, I think.