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

translate-platforms

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

translate-platforms

Translation API from multiple platforms.

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
increased by120%
Maintainers
1
Weekly downloads
 
Created
Source

Translate Platforms

A Node module to translate words by multiple platforms.

Installation

npm install translate-platforms

Usage

const { google, microsoft, youdao, baidu } = require('translate-platforms');
// async/await. The second parameter can be a language name (ISO 639-1)
const result = await google('Hello world', { to: google.ja });
console.log(result); 
// Output:
// {
//     lang: { from: 'en', to: 'ja' },
//     word: 'Hello world', 
//     text: 'こんにちは世界', 
//     candidate: [ 'こんにちは世界', 'こんにちは' ] 
// }
 
// Promises with .then(). The third parameter is the source language.
microsoft('こんにちは世界', { to: microsoft.zh }).then(result => {
  console.log(result);  
  // Output:
  // { 
  //     lang: { from: 'ja', to: 'zh' },
  //     word: 'こんにちは世界', 
  //     text: '你好世界', 
  //     candidate: [ ] 
  // }
});

Parameters

function translate(word: string, language: { from: string, to: string }): object
parameterdescription
wordThe word want to translate.
fromThe source language. Default is recognized automatically(auto). (Optional)
toThe target language. Default is Chinese(zh). (Optional)

Return Object

keydescription
langThe source language and target language.
wordThe word want to translate.
textThe most match result.
candidateOther translate result.

Language Code

Each platform supports different translation languages. You can check the interface function properties.

Support Platform

Supported platforms are Google, Microsoft, Yandex, Baidu, Tencent and Youdao.

Notice

Tencent does not support mutual translation of all languages, you can use the support function to get the translation language supported by the language.

Keywords

FAQs

Package last updated on 10 Apr 2020

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