npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

translateer

v2.0.2

Published

Light-weight Google translator in Node.js

Downloads

9

Readme

translateer

Light-weight translator

Installation

Using npm or yarn

npm install translateer --save
yarn add translateer --save

How to use

const translator  = require('tranlateer');

translate

translate is a function with only one object argument which is specified below.

q [optional] default is empty, the word/sentence you want to query. from [optional] default is auto, used to specify the language of q. to [optional] default is en, used to specify the language for translation. version [optional] default is 1.0, used to specify the version of API.

Examples for API v1.0 (Default)

translator.translate({
  q: 'hello world',
  to: 'es'
})
.then(res => res.json())
.then(console.log);

// Hola Mundo

Examples for API v2.0

translator.translate({
  q: 'hello world',
  to: 'es',
  v: '2.0'
})
.then(res => res.json())
.then(console.log);

/*
{
  "sentences": [
    {
      "trans": "Hola Mundo",
      "orig": "hello world",
      "backend": 1
    }
  ],
  "src": "en",
  "alternative_translations": [
    {
      "src_phrase": "hello world",
      "alternative": [
        {
          "word_postproc": "Hola Mundo",
          "score": 1000,
          "has_preceeding_space": true,
          "attach_to_next_token": false
        },
        {
          "word_postproc": "Hola Mundo",
          "score": 1000,
          "has_preceeding_space": true,
          "attach_to_next_token": false
        }
      ],
      "srcunicodeoffsets": [
        {
          "begin": 0,
          "end": 11
        }
      ],
      "raw_src_segment": "hello world",
      "start_pos": 0,
      "end_pos": 0
    }
  ],
  "confidence": 0.71052581,
  "ld_result": {
    "srclangs": [
      "en"
    ],
    "srclangs_confidences": [
      0.71052581
    ],
    "extended_srclangs": [
      "en"
    ]
  }
}
*/

getAudio

getAudio is a function returning the url of the audio file

q [optional] default is empty, the word/sentence you want to query. to [optional] default is auto detected, used to specify the language for translation. speed [optional] default is 1, used to specify the audio speed.

Example

translator.getAudio({
  q: 'hello world'
})
.then(console.log);
// https://translate.google.com/translate_tts?ie=UTF-8&q=test&tl=en&total=1&idx=0&textlen=4&tk=290146.141044&client=t&prev=input&ttsspeed=1 

Copyright

Copyright (C) 2017 Tony Ngan, released under the MIT License.