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-sdk

v1.0.2

Published

This SDK is used for string translation purposes. It provides command line interface to add, update and download the strings

Downloads

137

Readme

Transifex SDK

A node module which is used to perform transifex's operations such as

  1. Add resources to transifex
  2. Update resources on transifex
  3. Download translated strings of the resources from transifex

About

This node module connects with Transifex server using REST API to perform above operations for the translations. It adds new strings to transifex, download the translated strings from transifex and updates the existing strings on transifex.

Installation

npm install --save-dev transifex-sdk

Import

const { Translator, Transifex } = require('transifex-sdk');

Translator

It provides user interface on terminal where user can choose given options on command line tool to do operations like add, update or download resource.

Usage

const { Translator } = require('transifex-sdk');

const translator = new Translator({
  authToken: '<AUTH_TOKEN>',
  organizationSlug: '<ORGANIZATION_SLUG>',
  projectSlug: '<PROJECT_SLUG>',
});

Options

| Name | Type | Default Value | Description | | ---------------- | ------ | ------------- | ------------------------------------------------------------------------------------------- | | authToken | String | required | Auth token is used to authenticate the user | | organizationSlug | String | required | Organization's slug | | projectSlug | String | required | Project's slug | | rootPath | String | "./" | Directory path where all strings are generated | | localesMap | Object | {} | Mapping of json file's names | | resourceName | String | "" | Useful for those projects where only one source file is being used |

localesMap:

This parameter is used to change default name of the generated resource(json file). For example, if default name of the json file for the Korean locale is ko_KR.json then It can be changed to ko.json by adding key-value pair in the localesMap object.

const localesMap = {
  ko_KR: 'ko',
};

resourceName:

This parameter is used when there is only one json file in the same project. By using it, Selection of resource (which resource should be downloaded or uploaded) options will not be appeared on CLI.

Methods

init(): To start the SDK

/**
 * This method is used to initialize the SDK.
 *
 * @method init
 * @returns {void}
 */
translator.init();

Transifex

This is a core library which provides methods to perform transifex's operation. It doesn't show interactive command line tool like translator.

Usage

const transifex = new Transifex({
  authToken: '<AUTH_TOKEN>',
  organizationSlug: '<ORGANIZATION_SLUG>',
  projectSlug: '<PROJECT_SLUG>',
});

Methods

get(): To get resources

/**
 * This method is used to get list of resources from transifex
 *
 * @method get
 * @returns {Promise}
 */
transifex.get();

create(): To create a resource

/**
 * This method is used to create a new resource on transifex.
 *
 * @method create
 * @param {string} resourceName [holds the name of the resource which is to be created on transifex]
 * @returns {Promise}
 */
transifex.create(resourceName);

upload(): To upload strings of a resource

/**
 * This method is used to upload strings on transifex which are to be translated by transifex
 *
 * @method upload
 * @param {JSON | Object} strings [holds source strings]
 * @param {string} resourceName [holds the name of the resource]
 * @returns {Promise}
 */
transifex.upload(strings, resourceName);

download(): To download strings of a resource

/**
 * This method is used to download resource's strings from transifex. (source strings | translated strings)
 *
 * @method download
 * @param {Boolean} translated [whether translated or source strings will be downloaded]
 * @param {string} resourceName [holds name of the resource]
 * @param {string} [locale] [holds locale name for which resource to be downloaded]
 * @returns {Promise}
 */
transifex.download(translated = true, resourceName, locale);

getSupportedLanguages(): To get supported languges

/**
 * This method is used to fetch all the supported languages
 * 
 * @method getSupportedLanguages
 * @returns {Promise}
 */
transifex.getSupportedLanguages();

Author

Sanjay Yadav