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

transifex-api-es6

v0.2.4

Published

Promise-based Transifex API client for node, written in es6

Downloads

7

Readme

view on npm Dependency Status

transifex-api-es6

A promise-based Transifex API client for node, written in es6. Promises are thenable using the q library.

The motivation behind this API is that there are no modern, promise-based JS API for Transifex out there that I could find. If found those that exist being difficult to overview or understand, so I started building on a new one.

Installation

npm install [--save] [--save-dev] transifex-api-es6

Usage

var TransifexApi = require('transifex-api-es6');

var api = new TransifexApi({
  user: 'username',
  password: 'password',
  projectName: 'my-project',
  resourceName: 'customer-area' // optional
});

// Get resource translation
api.getResourceTranslation('en')
.then((contents) => {
  // contents -> PO contents as a string
}, (err) => console.error(err));

// Get translation strings
api.getTranslationStrings('en', 'my_resource')
.then((strings) => {
  // strings -> Set of string objects for 'my_resource'
}, (err) => console.error(err))

API Reference

new TransifexApi(opts)

| Param | Type | Description | | --- | --- | --- | | opts | Object | An object with required projectName, user and password fields. Optionally takes a resourceName which is stored as the default resource. |

transifexApi.setResourceName(resourceName)

Sets the default resource slug

| Param | Type | Description | | --- | --- | --- | | resourceName | string | A resource slug |

transifexApi.getProject() ⇒ Object

Returns information about the project

Returns: Object - A project instance (wrapped in a promise)

transifexApi.getProjectLanguages() ⇒ Object

Returns an list of languages that belong to the project

Returns: Object - A list of languages (wrapped in a promise)

transifexApi.getResources() ⇒ array

Returns a list of resources in the project

Returns: array - A list of the project's resources (wrapped in a promise)

transifexApi.getResource(resourceName) ⇒ Object

Returns a resource

| Param | Type | Description | | --- | --- | --- | | resourceName | string | (Optional) The slug of the requested resource. |

Returns: Object - A resource as JSON (wrapped in a promise)

transifexApi.createResource(resource) ⇒ Object

Creates a new resources in the project

| Param | Type | Description | | --- | --- | --- | | resource | Object | Dictionary with info about the resource |

Returns: Object - A q promise

transifexApi.deleteResource(resourceName) ⇒ Object

Deletes a resource

| Param | Type | Description | | --- | --- | --- | | resourceName | string | (Optional) The slug of the resource |

Returns: Object - A q promise

transifexApi.getResourceTranslation(langCode, resourceName) ⇒ string

Returns a translation of a given (or default) resource in a given language as .po contents.

| Param | Type | Description | | --- | --- | --- | | langCode | string | A language code, e.g. en_US | | resourceName | string | (Optional) A resource slug |

Returns: string - A PO file as a string (wrapped in a promise)

transifexApi.getTranslationStrings(langCode, resourceName) ⇒ string

Returns a set of translated strings of a given (or default) resource in a given language.

| Param | Type | Description | | --- | --- | --- | | langCode | string | A language code, e.g. en_US | | resourceName | string | (Optional) A resource slug |

Returns: string - A list of translation strings as JSON objects
(wrapped in a promise)

Contributing

This project is in early development. Issues and pull requests are more than welcome!