Coder Social home page Coder Social logo

john-theo / google-translate-server Goto Github PK

View Code? Open in Web Editor NEW
151.0 2.0 25.0 39 KB

[DEPRECATED] Free Google Translate API. Very lightweight and easy to use.

Dockerfile 7.13% JavaScript 92.87%
server google-translate google-translate-api api javascript nodejs express docker deprecated

google-translate-server's Introduction

Google Translate Server

No Maintenance Intended

!!!DEPRECATED!!!

After a lot of "googling", I'm sorry to confirm that similar approaches are NO LONGER WORKING now. And you HAVE TO own a Google Developer account for the simple task.

BUT! DO try out the DeepL API! As far as my uses cases are concerned, it works a lot better than Google Translate! Everyone end up here comes for the same reason, and I hope DeepL can be a better successor for you!


A express.js server wrapper for google-translate-cn-api

Use Google Translate API WITHOUT a Google account!

Features

  • Updated, use Google Translate Web API;
  • Open Source, FREE forever;
  • Cross Language, simple REST API, basic url request in any language;
  • Fast, choose your local Google Translate domian (eg. https://translate.google.cn/);
  • Auto Correction;
  • ZERO Config, docker ready, start service in 1 minute.

Example

Request

curl http://localhost:30031/?text=I spea Dutch!&to=zh-cn

Response

{
  "text": "我说荷兰语!",
  "from": {
    "language": {
      "didYouMean": false,
      "iso": "en"
    },
    "text": {
      "autoCorrected": false,
      "value": "I speak Dutch!",
      "didYouMean": true
    }
  },
  "raw": ""
}

Use docker Recommended

docker run -it --rm -p 30031:30031 -e "DOMAIN=cn" johndope/google-translate-server

Run directly

Install

npm i

Usage

# start with default port 30031
npm start

# specify port
yarn start -- -p 30032

# specify domain
# eg: translate.google.cn
# default: translate.google.com
yarn start -- -d cn

Use docker-compose

# start with default port 30031
docker-compose up

# specify port
PORT=30032 docker-compose up

# specify domain
DOMAIN=cn docker-compose up

Client Example

curl

curl http://localhost:30031/?text=hello&to=zh-cn

python

import requests
from urllib.parse import urlencode

print(requests.get('http://localhost:30031/?'+urlencode({
    'text': 'I spea Dutch!',  # this input will trigger auto-suggestion
    'from': 'en',  # leave blank to auto detect
    'to': 'zh-cn',
    # 'raw': 'true',  # response contains unparsed response
    # 'domain': 'cn'  # change google translate domain, overrides default domain
})).json())

More details about query parameters: google-translate-api and google-translate-cn-api.

It's worth mention that, with google-translate-cn-api, you can now specify something like domain: 'cn' in the parameter to use your local Google Translate domain. Mode details can be found here.

Credit

Repository

Github: John-Theo/google-translate-server

Docker Hub: johndope/google-translate-server

License

This application comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.