All Projects → wilsonwu → translation-google

wilsonwu / translation-google

Licence: MIT license
A Google Translate component for Nodejs.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to translation-google

HighlightTranslator
Highlight Translator can help you to translate the words quickly and accurately. By only highlighting, copying, or screenshoting the content you want to translate anywhere on your computer (ex. PDF, PPT, WORD etc.), the translated results will then be automatically displayed before you.
Stars: ✭ 54 (+28.57%)
Mutual labels:  translate, google-translate, google-translate-api
translate
A module grouping multiple translation APIs
Stars: ✭ 321 (+664.29%)
Mutual labels:  translate, google-translate
google-translate-tk
Calculate google translate's token(tk) by Golang
Stars: ✭ 33 (-21.43%)
Mutual labels:  google-translate, google-translate-api
googletrans
G文⚡️: Concurrency-safe, Free and Unlimited google translate api for Golang. 🔥免费、无限、并发安全的谷歌翻译包
Stars: ✭ 94 (+123.81%)
Mutual labels:  google-translate, google-translate-api
po-auto-translation
translate PO files automatically for FREE using google translate
Stars: ✭ 33 (-21.43%)
Mutual labels:  translate, google-translate
php-google-translate-for-free
Library for free use Google Translator. With attempts connecting on failure and array support.
Stars: ✭ 124 (+195.24%)
Mutual labels:  translate, google-translate
node-google-translate-skidz
Simple Node.js library for talking to Google's Translate API for free.
Stars: ✭ 70 (+66.67%)
Mutual labels:  translate, google-translate
tr4n5l4te
Use Google Translate without an API key.
Stars: ✭ 32 (-23.81%)
Mutual labels:  translate, google-translate
React Translated
A dead simple way to add complex translations (i18n) in a React (DOM/Native) project 🌎🌍🌏
Stars: ✭ 176 (+319.05%)
Mutual labels:  translate
Vscode Comment Translate
vscode 注释翻译插件, 不干扰正常代码,方便快速阅读源码。
Stars: ✭ 235 (+459.52%)
Mutual labels:  translate
Google Translate
🈯 A Node.JS library to consume Google Translate API for free.
Stars: ✭ 152 (+261.9%)
Mutual labels:  translate
Cv Translation
我叫CV翻译,因为我的精髓就是Ctrl + c 不用v (原名QTranser)
Stars: ✭ 180 (+328.57%)
Mutual labels:  translate
Tms
基于频道模式的团队沟通协作+轻量级任务看板,支持mardown、富文本、在线表格和思维导图的团队博文wiki,i18n国际化翻译管理的响应式web开源团队协作系统。
Stars: ✭ 232 (+452.38%)
Mutual labels:  translate
Youdaotranslate
Alfred Youdao Translate Workflow
Stars: ✭ 2,344 (+5480.95%)
Mutual labels:  translate
tripreader-data
“读卡识途”项目公开数据
Stars: ✭ 58 (+38.1%)
Mutual labels:  china
Deeply
PHP client for the DeepL.com translation API (unofficial)
Stars: ✭ 152 (+261.9%)
Mutual labels:  translate
Google Translate Api
A free and unlimited API for Google Translate 💵🚫
Stars: ✭ 1,996 (+4652.38%)
Mutual labels:  translate
Flutter translate
Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
Stars: ✭ 245 (+483.33%)
Mutual labels:  translate
Traduzir Paginas Web
Translate your page in real time using Google or Yandex.
Stars: ✭ 214 (+409.52%)
Mutual labels:  translate
Yii2 Translate Manager
Translation Manager
Stars: ✭ 221 (+426.19%)
Mutual labels:  translate

translation-google

Downloads Version License

A Google Translate API: WARNING: There is IP banned risk from Google Translate when you use this way to do translation.

Features

  • Translate all languages that Google Translate supports.
  • Support different area (Support Chinese user, in China Mainland could set the suffix to 'cn' to make it work)

Live Demo with Nodejs

Edit translation-google-demo

Install

npm install translation-google

Usage

From automatic language detection to English:

var translate = require('translation-google');

translate('This is Google Translate', {to: 'zh-cn'}).then(res => {
    console.log(res.text);
    //=> 这是Google翻译
    console.log(res.from.language.iso);
    //=> en
}).catch(err => {
    console.error(err);
});

For Chinese user, try this:

var translate = require('translation-google');

translate.suffix = 'cn'; // also can be 'fr', 'de' and so on, default is 'com'

translate('This is Google Translate', {to: 'zh-cn'}).then(res => {
    console.log(res.text);
    //=> 这是Google翻译
    console.log(res.from.language.iso);
    //=> en
}).catch(err => {
    console.error(err);
});

Sometimes, the API will not use the auto corrected text in the translation:

translate('This is Google Translat', {from: 'en', to: 'zh-cn'}).then(res => {
    console.log(res);
    console.log(res.text);
    //=> 这是Google翻译
    console.log(res.from.text.autoCorrected);
    //=> false
    console.log(res.from.text.value);
    //=> This is Google [Translate]
    console.log(res.from.text.didYouMean);
    //=> true
}).catch(err => {
    console.error(err);
});

API

translate(text, options)

text

Type: string

The text to be translated

options

Type: object

from

Type: string Default: auto

The text language. Must be auto or one of the codes/names (not case sensitive) contained in languages.js

to

Type: string Default: en

The language in which the text should be translated. Must be one of the codes/names (not case sensitive) contained in languages.js.

raw

Type: boolean Default: false

If true, the returned object will have a raw property with the raw response (string) from Google Translate.

Returns an object:

  • text (string) – The translated text.
  • from (object)
    • language (object)
      • didYouMean (boolean) - true if the API suggest a correction in the source language
      • iso (string) - The code of the language that the API has recognized in the text
    • text (object)
      • autoCorrected (boolean)true if the API has auto corrected the text
      • value (string) – The auto corrected text or the text with suggested corrections
      • didYouMean (booelan)true if the API has suggested corrections to the text
  • raw (string) - If options.raw is true, the raw response from Google Translate servers. Otherwise, ''.

Note that res.from.text will only be returned if from.text.autoCorrected or from.text.didYouMean equals to true. In this case, it will have the corrections delimited with brackets ([ ]):

translate('This is Google Translat').then(res => {
    console.log(res.from.text.value);
    //=> This is [Google Translate]
}).catch(err => {
    console.error(err);
});

Otherwise, it will be an empty string ('').

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].