Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/translate

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/translate

Cloud Translation API Client Library for Node.js

  • 7.2.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @google-cloud/translate?

@google-cloud/translate is a Node.js client library for Google Cloud Translation API. It allows developers to translate text between thousands of language pairs, detect the language of text, and get a list of supported languages.

What are @google-cloud/translate's main functionalities?

Translate Text

This feature allows you to translate text from one language to another. In this example, the text 'Hello, world!' is translated to Spanish ('es').

const {Translate} = require('@google-cloud/translate').v2;
const translate = new Translate();

async function translateText() {
  const text = 'Hello, world!';
  const target = 'es';

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

translateText();

Detect Language

This feature allows you to detect the language of a given text. In this example, the language of 'Bonjour le monde' is detected.

const {Translate} = require('@google-cloud/translate').v2;
const translate = new Translate();

async function detectLanguage() {
  const text = 'Bonjour le monde';

  const [detection] = await translate.detect(text);
  console.log(`Text: ${text}`);
  console.log(`Language: ${detection.language}`);
}

detectLanguage();

List Supported Languages

This feature allows you to get a list of all supported languages for translation. The example code retrieves and prints the list of supported languages.

const {Translate} = require('@google-cloud/translate').v2;
const translate = new Translate();

async function listLanguages() {
  const [languages] = await translate.getLanguages();
  console.log('Languages:', languages);
}

listLanguages();

Other packages similar to @google-cloud/translate

Keywords

FAQs

Package last updated on 14 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc