0.1.6 • Published 10 years ago

onesky v0.1.6

Weekly downloads
5,185
License
MIT
Repository
github
Last release
10 years ago

OneSky API for Node

This Node.js module provides access to the OneSky API for managing website translations.

Note: This module uses Onesky's "Classic API". Onesky has since released a new API called the Platform API. We should eventually migrate this module to the new API.

If you're looking for a service to order human translations, check out node-gengo.

Installation

Install via npm

npm install onesky --save

Usage

Initialize onesky with your public and private keys.

var onesky = require('onesky')(publicKey, privateKey);
Example calls

Note: All callbacks are passed an error and data argument: callback(err, data).

Create project with base locale en_US

onesky.project.add('My app', 'en_US', callback);

Fetch project

onesky.project.details('My app', callback);

Add a platform to a project

onesky.platform.add('My app', { type: 'website' }, callback);

Add a phrase to a platform. Strings parameter can be an object, array of objects, string, or an array of strings

var strings = [{
  string: 'My webapp is cool',
  stringKey: 'homepage.webapp_is_cool'
}, {
  string: 'Another sentence, without a stringKey'
}];

onesky.string.input(platformId, strings, callback);

Order translations

onesky.translate.order({
  platformId: platformId,
  agencyId: 5,
  toLocale: 'es_ES',
  filter: 'ALL'
}, callback);

Fetch translations

onesky.string.output({
  platformId: platformId,
  locale: 'es_ES'
}, callback);

For additional methods, see Onesky's documentation. All endpoints and options listed in the official API docs are available here.

Contribute

Forks and pull requests welcome!

TODO

  • Add tests
  • Parse OneSky's response when approriate. OneSky often returns unnecessary nesting
  • Design a better way of defining API keys to allow use of multiple onesky accounts

Author

Brandon Paton. Email me if you have any questions: bp@brandonpaton.com. Support by Localize.js.