# transifex-api-es6

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

Latest version **0.2.4** (published 2018-09-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install transifex-api-es6
pnpm add transifex-api-es6
yarn add transifex-api-es6
bun add transifex-api-es6
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2018-09-09 |
| First published | 2015-11-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Alexander Wallin |
| Maintainers | alexander_wallin |
| Keywords | transifex |

## Links

- npm: https://www.npmjs.com/package/transifex-api-es6
- Repository: https://github.com/alexanderwallin/transifex-api-es6
- Issues: https://github.com/alexanderwallin/transifex-api-es6/issues
- npm.io page: https://npm.io/package/transifex-api-es6

## Dependencies (2)

- [q](https://npm.io/package/q.md) ^1.4.1
- [request](https://npm.io/package/request.md) ^2.68.0

## Recent versions

- 0.2.4 (latest) — 2018-09-09
- 0.2.3 — 2016-08-17
- 0.2.2 — 2015-12-10
- 0.2.1 — 2015-12-10
- 0.2.0 — 2015-12-09
- 0.1.3 — 2015-12-09
- 0.1.2 — 2015-12-09
- 0.1.1 — 2015-11-15
- 0.1.0 — 2015-11-15
- 0.0.2 — 2015-11-10
- 0.0.1 — 2015-11-10

## README

[![view on npm](http://img.shields.io/npm/v/transifex-api-es6.svg)](https://www.npmjs.org/package/transifex-api-es6)
[![Dependency Status](https://david-dm.org/alexanderwallin/transifex-api-es6.svg)](https://david-dm.org/alexanderwallin/transifex-api-es6)

# transifex-api-es6

A promise-based Transifex API client for node, written in es6. Promises are thenable using the [q library](https://github.com/kriskowal/q).

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](#Installation)
* [Usage](#Usage)
* [API Reference](#API_Reference)
* [Contributing](#Contributing)

<a name="Installation"></a>
## Installation

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

<a name="Usage"></a>
## Usage

```javascript
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))
```

<a name="API_Reference"></a>
## API Reference


* [TransifexApi](#TransifexApi)
  * [new TransifexApi(opts)](#new_TransifexApi_new)
  * [.setResourceName(resourceName)](#TransifexApi+setResourceName)
  * [.getProject()](#TransifexApi+getProject) ⇒ <code>Object</code>
  * [.getProjectLanguages()](#TransifexApi+getProjectLanguages) ⇒ <code>Object</code>
  * [.getResources()](#TransifexApi+getResources) ⇒ <code>array</code>
  * [.getResource(resourceName)](#TransifexApi+getResource) ⇒ <code>Object</code>
  * [.createResource(resource)](#TransifexApi+createResource) ⇒ <code>Object</code>
  * [.deleteResource(resourceName)](#TransifexApi+deleteResource) ⇒ <code>Object</code>
  * [.getResourceTranslation(langCode, resourceName)](#TransifexApi+getResourceTranslation) ⇒ <code>string</code>
  * [.getTranslationStrings(langCode, resourceName)](#TransifexApi+getTranslationStrings) ⇒ <code>string</code>

<a name="new_TransifexApi_new"></a>
#### new TransifexApi(opts)

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

<a name="TransifexApi+setResourceName"></a>
#### transifexApi.setResourceName(resourceName)
Sets the default resource slug


| Param | Type | Description |
| --- | --- | --- |
| resourceName | <code>string</code> | A resource slug |

<a name="TransifexApi+getProject"></a>
#### transifexApi.getProject() ⇒ <code>Object</code>
Returns information about the project

**Returns**: <code>Object</code> - A project instance (wrapped in a promise)  
<a name="TransifexApi+getProjectLanguages"></a>
#### transifexApi.getProjectLanguages() ⇒ <code>Object</code>
Returns an list of languages that belong to the project

**Returns**: <code>Object</code> - A list of languages (wrapped in a promise)  
<a name="TransifexApi+getResources"></a>
#### transifexApi.getResources() ⇒ <code>array</code>
Returns a list of resources in the project

**Returns**: <code>array</code> - A list of the project's resources (wrapped in a promise)  
<a name="TransifexApi+getResource"></a>
#### transifexApi.getResource(resourceName) ⇒ <code>Object</code>
Returns a resource


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

**Returns**: <code>Object</code> - A resource as JSON (wrapped in a promise)  
<a name="TransifexApi+createResource"></a>
#### transifexApi.createResource(resource) ⇒ <code>Object</code>
Creates a new resources in the project


| Param | Type | Description |
| --- | --- | --- |
| resource | <code>Object</code> | Dictionary with info about the resource |

**Returns**: <code>Object</code> - A q promise  
<a name="TransifexApi+deleteResource"></a>
#### transifexApi.deleteResource(resourceName) ⇒ <code>Object</code>
Deletes a resource


| Param | Type | Description |
| --- | --- | --- |
| resourceName | <code>string</code> | (Optional) The slug of the resource |

**Returns**: <code>Object</code> - A q promise  
<a name="TransifexApi+getResourceTranslation"></a>
#### transifexApi.getResourceTranslation(langCode, resourceName) ⇒ <code>string</code>
Returns a translation of a given (or default) resource in a given language
as .po contents.


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

**Returns**: <code>string</code> - A PO file as a string (wrapped in a promise)  
<a name="TransifexApi+getTranslationStrings"></a>
#### transifexApi.getTranslationStrings(langCode, resourceName) ⇒ <code>string</code>
Returns a set of translated strings of a given (or default) resource in a
given language.


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

**Returns**: <code>string</code> - A list of translation strings as JSON objects  
                              (wrapped in a promise)  

<a name="Contributing"></a>
## Contributing

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

---
_Source: https://npm.io/package/transifex-api-es6 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
