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

gengo-node

v1.0.2

Published

A client for Gengo's human translation API

Downloads

12

Readme

  • Under development *

GENGO'S HUMAN TRANSLATION API

Gengo makes it easy to plug human powered translation in to your service or platform.

Install

$npm install gengo-node

require

Gengo = require Gengo
gengoClient = new Gengo {public: YOUR_PUBLIC_KEY, private: your_private_key}

By default the client sends all requests to the Gengo Sandbox environment.

Send a couple of jobs for translation

First we create a couple of jobs that represent a blog post. I've only set a few of the options here, but check out the job payloads for a full list.

blog_post =
  title:
    lc_src: 'en'
    lc_tgt: 'ja'
    tier: 'standard'
    body_src: "This is the title of my blog post"
    custom_data: {blog_post_id: 2322, part: 'title'}
    callback_url: "http://mysite.com/gengo_callback/"
  body:
    lc_src: 'en'
    lc_tgt: 'ja'
    tier: 'standard'
    body_src: "This is the body content of my blog post"
    custom_data: {blog_post_id: 2322, part: 'body'}
    callback_url: "http://mysite.com/gengo_callback/"

There are two important concepts in this payload.

  1. custom_data: Here we've added 2 bits of information that will help us map the translated content back to our own system. In this example a blog post ID and the part of the post.

  2. callback_url: Since there will be real human translators working on the content it may take a bit of time. Once the translation is ready we'll post the translation to the URL provided along with the custom_data and order details.

Since the Gengo API is designed to support thousnads of jobs, there is a queueing mechanism placed in front of the API. This means that when a jobs are sent, we reply with an order_id and put the jobs in a queue.

blog_post_order_id = null
Gengo.postJobs blog_post, (res) ->
  blog_post_order_id = res.order_id
  console.log res

  ###
  {
    "order_id": "139370",
    "group_id": 23015,
    "job_count": "2",
    "credits_used": "3.50",
    "currency": "USD"
  }
  ###

Now that we have the order ID we can check on the status of the order.

blog_post_job_ids = null
Gengo.getOrder blog_post_order_id, (res) ->
  blog_post_job_ids = res.order.jobs_available
  console.log res

  ###
  {
    "order": {
      "order_id": "139370",
      "total_credits": "3.50",
      "currency": "USD",
      "total_units": 17,
      "as_group": 1,
      "jobs_available": [
        "243646",
        "243647",
      ],
      "jobs_pending": [],
      "jobs_reviewable": [],
      "jobs_approved": [],
      "jobs_queued": 0,
      "total_jobs": "2"
    }
  }
  ###