transifex-client

    0.0.1 • Public • Published

    Transifex Client

    A HTTP API client for the Transifex translation service.

    var TransifexClient = require('transifex-client');
    var transifex = new TransifexClient({
        username: 'translator',
        password: 'password'
    });
     
    transifex.projects.get({project: 'sample-project'}, function(err, data) {
        console.log(data.description);
    });

    If no callback is provided, a readable stream is returned.

    var translations = transifex.translations.get({
        project: 'sample-project',
        resource: 'sample',
        language: 'es'
    }, {
        parse: false
    });
     
    translations
        .pipe(fs.createWritableStream('./sample-project.es.json'));

    Roadmap to 1.0

    • Request and handle gzip content
    • Support streaming responses
    • Implement methods for retrieving translations for a project
    • Implement uploading new and updated resources
    • Implement removing resources
    • Implement languages
    • Implement resource strings
    • Implement statistics
    • Create unit tests
    • Setup Travis CI
    • Should "get*" methods exist? If not, how should this API be organized?
    • Finalize API

    TransifexClient

    • username
    • password

    TransifexClient.prototype.formats

    get

    transifex.formats.get(function(err, resp) {
        console.log(resp.body.XLIFF)
    });

    TransifexClient.prototype.languages

    get

    transifex.languages.get(function(err, resp) {
        console.log(resp.body[0].name);
    });

    getLanguage

    • language
    transifex.languages.getLanguage({language: 'pt_BR'}, function(err, resp) {
        console.log(resp.body.name);
    });

    TransifexClient.prototype.projects

    get

    • project
    transifex.projects.get({
        project: 'sample-project',
        query: {
            details: true
        }
    }, function(err, resp) {
        console.log(resp.body.description);
    });

    TransifexClient.prototype.resources

    get

    • project
    transifex.resources.get({project: 'sample-project'}, function(err, resp) {
        console.log(resp.body[0].slug);
    });

    getResource

    • project
    • resource
    transifex.resources.getResource({
        project: 'sample-project',
        resource: 'sample',
        query: {
            details: true
        }
    }, function(err, resp) {
        console.log(resp.body.wordcount);
    });

    TransifexClient.prototype.translations

    get

    • project
    • resource (file)
    • language
    transifex.translations.get({
        project: 'sample-project',
        resource: 'sample',
        language: 'es'
    }, function(err, resp) {
        console.log(resp.body);
    });

    Install

    npm i transifex-client

    DownloadsWeekly Downloads

    28

    Version

    0.0.1

    License

    MIT

    Last publish

    Collaborators

    • terinjokes