Skip to content
Node.js client for Google Cloud Translate: Dynamically translate text between thousands of language pairs.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: move CONTRIBUTING.md to root (#211) Feb 7, 2019
.kokoro build: updated kokoro config for coverage and release-please (#269) May 17, 2019
protos/google/cloud/translate/v3beta1 feat: add version v3beta1 (#232) Apr 2, 2019
samples docs: generate new samples/README.md, README.md (#268) May 20, 2019
src fix: DEADLINE_EXCEEDED is idempotent (#264) May 10, 2019
system-test chore(deps): update dependency gts to v1 (#246) May 3, 2019
test chore(deps): update dependency gts to v1 (#246) May 3, 2019
.clang-format feat: convert to TypeScript (#63) Jul 10, 2018
.eslintignore chore: update nyc and eslint configs (#194) Dec 11, 2018
.eslintrc.yml Enable prefer-const in the eslint config (#123) Sep 20, 2018
.gitignore feat: add version v3beta1 (#232) Apr 2, 2019
.jsdoc.js build: check broken links in generated docs (#202) Jan 10, 2019
.nycrc update to .nycrc with --all enabled (#247) Apr 29, 2019
.prettierignore Repo Migration (#6) Oct 24, 2017
.prettierrc Repo Migration (#6) Oct 24, 2017
.readme-partials.yml docs: generate new samples/README.md, README.md (#268) May 20, 2019
.repo-metadata.json docs: generate new samples/README.md, README.md (#268) May 20, 2019
CHANGELOG.md chore: release 4.0.1 (#273) May 20, 2019
CODE_OF_CONDUCT.md chore: run repo tools (#96) Aug 16, 2018
CONTRIBUTING.md docs: update links in contrib guide (#218) Feb 14, 2019
LICENSE chore: update license file (#182) Dec 4, 2018
README.md docs: generate new samples/README.md, README.md (#268) May 20, 2019
codecov.yaml Update CI config (#135) Sep 28, 2018
package.json chore: use published jsdoc-baseline package (#276) May 23, 2019
renovate.json chore: ignore package-lock.json (#91) Aug 7, 2018
synth.metadata docs: generate new samples/README.md, README.md (#268) May 20, 2019
synth.py feat: add version v3beta1 (#232) Apr 2, 2019
tsconfig.json Enable noImplicitThis in tsconfig (#115) Sep 5, 2018
tslint.json feat: convert to TypeScript (#63) Jul 10, 2018

README.md

Google Cloud Platform logo

The Cloud Translation API, can dynamically translate text between thousands of language pairs. The Cloud Translation API lets websites and programs integrate with the translation service programmatically. The Cloud Translation API is part of the larger Cloud Machine Learning API family.

release level npm version codecov

Cloud Translation API Client Library for Node.js

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Cloud Translation API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/translate

Using the client library

async function main(
  projectId = 'YOUR_PROJECT_ID' // Your GCP Project Id
) {
  // Imports the Google Cloud client library
  const {Translate} = require('@google-cloud/translate');

  // Instantiates a client
  const translate = new Translate({projectId});

  // The text to translate
  const text = 'Hello, world!';

  // The target language
  const target = 'ru';

  // Translates some text into Russian
  const [translation] = await translate.translate(text, target);
  console.log(`Text: ${text}`);
  console.log(`Translation: ${translation}`);
}

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Quickstart source code Open in Cloud Shell
Translate source code Open in Cloud Shell

The Cloud Translation Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

You can’t perform that action at this time.