Fix typo
Use shell-session throughout README
Split gtranslate-server and gtranslate-query
Better front-end for Google Translate that is lightweight, doesn't track you and works without JavaScript.
As well as a web UI, gtranslate
provides a simple REST API to fetch
translations, it can be accessed on /api
endpoint with the GET
method. It
accepts the following query parameters:
from
- code of the language to translate from (use auto
to auto-detect)to
- code of the language to translate totext
- text to translateLanguage codes are standard ISO-639 codes. Full list of them is available in
languages.go
in the source.
Example using curl:
$ curl 'https://your.gtranslate.instance/api?from=en&to=fr&text=Hello'
Bonjour
$ git clone https://git.sr.ht/~yerinalexey/gtranslate
$ cd gtranslate
$ make
And optionally:
# make install
$ ./gtranslate-server
Note: if you're running it outside of development environment, you
should pass --templates-dir
and --static-dir
arguments pointing to
templates and static directories:
$ ./gtranslate-server \
--templates-dir path/to/gtranslate/templates \
--static-dir path/to/gtranslate/static
Other settings (available with ./gtranslate-server --help
):
Usage of ./gtranslate-server:
-b, --bind string Address to bind the server to, [addr]:port (default ":5000")
--proxy string Proxy URL, with no scheme http is assumed
--static-dir string Static files directory (default "./static")
--templates-dir string Templates directory (default "./templates")
--user-agent string User-Agent header to use
A gtranslate-query
tool is also provided. It mirrors server's API into a
command-line application.
$ gtranslate-query en fr "Hello"
Bonjour
Usage: ./gtranslate-query [flags] <from> <to> <text>
Flags:
--proxy string Proxy URL, with no scheme http is assumed
--user-agent string User-Agent header to use
Routing requests through Tor has its benefits:
gtranslate
servers as they act like normal Tor usersDespite that, it has some drawbacks:
First of, you need to set up Tor daemon on the server. Here's a guide on ArchWiki: Tor.
With default settings, it should start a SOCKS5 proxy on localhost, port 9050.
Also, to minimize fingerprint, you need to use a very common user agent on Tor network. And, you guessed it, get it straight from Tor Browser. If you have one, you can just open https://httpbin.org/headers and copy it from there. If not, the latest available is provided here: Tor Browser's User-Agent.
Full setup:
./gtranslate-server \
--user-agent "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0" \
--proxy "socks5://localhost:9050" \
...
If you have managed to set it up or experienced issues with this guide, feel free to shoot an email to my public inbox.