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

cimpress-translations

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cimpress-translations

Lightweight client for the Translations Service

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cimpress-translations

npm version

cimpress-translations is a convenient client for Cimpress' Translations service.

Features:

  • list and describe services; get language blobs for a language
  • pick language using ISO-639-2 ('eng', 'fra') or by passing the language's English name ('English', 'French')
  • supply authorization statically (using a hard-coded string) or dynamically (with a custom method)
  • convenience of a default service URL with the possibility of an override

Getting Started

Include cimpress-translations in your project using npm or yarn:

npm install --save cimpress-translations

Require the module with:

const { TranslationsClient } = require("cimpress-translations");

Consuming the API

new TranslationsClient(url, auth)

Instantiates a new client. Pass null for url to use the default service URL. auth may be a string or a synchronous/asynchronous function returning a string.

client.listServices()

Lists all services for which you can access translations.

let services = await client.listServices();
console.log(services);
/**
 * {
 *   "services": [
 *     {
 *       "serviceId": "28b1f0d2-9366-40cb-95bd-14de8c3adb9b"
 *       "name": ...
 *
client.describeService(serviceId)

Returns details about a service.

let services = await client.describeService("28b1f0d2-9366-40cb-95bd-14de8c3adb9b");
console.log(service);
/**
 * {
 *   "serviceId": "28b1f0d2-9366-40cb-95bd-14de8c3adb9b"
 *   "name": "My Cimpress Service",
 *   "configuration": ...
 *
client.getLanguageBlob(serviceId, language)

Retrieves the translation for a service in a given language. The language may be specified using ISO-639-2 ('eng', 'fra') or selected using its English name ('English', 'French').

let services = await client.getLanguageBlob("28b1f0d2-9366-40cb-95bd-14de8c3adb9b", "French");
console.log(service);
/**
 * {
 *   "blobId": "8a27db52-3245-4466-be94-5e9f39283a3b",
 *   "data": ...
 *

Error handling

Identify errors by checking their name property.

EGENERIC

An unspecified error has occured.

ENOACCESS

You are not authenticated or authorized to read this information.

ENOTFOUND

The service was not found of does not support this language.

ENOLANG

The requested language was not found amongst languages specified in ISO-639-2.

Built With

Contributing

Have you benefited from this library? Have you found or fixed a bug? Would you like to see a new feature implemented? We are eager to collaborate with you on GitHub.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache 2.0 license - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 14 May 2018

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