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

gulp-transifex

v0.1.17

Published

Gulp plugin for uploading source languages files to transifex

Downloads

327

Readme

gulp-transifex

Gulp plugin for uploading resources and downloading translations in Transifex

Feel free to fork and improve

Usage

var options = {
    host: <String optional. Defaults to 'www.transifex.com'>,
    base_path: <String optional. Defaults to '/api/2/project/'>,
    user: <String required. Transifex username>,
    password: <String required. Transifex Password>,
    project: <String required. Transifex projects name>,
    local_path: <String optional. Local root path for the translations>,
    custom_language_codes:{
        <ISO 639-1 language code>: <custom language code>
    },
    use_custom_language_codes: <Boolean>,
    language_codes_as_objects: <Boolean>
}

Using Custom Language Codes

Transifex uses ISO 639-1 to code languages. If you want to use your custom language code (another standard or just map es to Klingon) use the custom_language_codes option with use_custom_language_codes set to true.

###language_codes_as_objects By default the languages() method returns an array of strings with the language codes. If you specify custom_language_codes AND use_custom_language_codes is set to true, it will return an array of strings with your own custom codes. Additionally, if language_codes_as_objects is set to true it will return an array of object in the form:

[
    {
        <ISO 639-1 language code>: <custom language code>
    },
    ...
]

Uploading Resource files:

gulp-transifex will go file by file uploading them to the project as a resource Transifex will check if the file has changed and will store the changes

var transifex = require('transifex').createClient(options)
var gulp = require('gulp')

gulp.task('upstream', function(){
    gulp.src('path/to/source/language/*')
        .pipe(transifex.pushResource())
})

Downloading translation files:

Similarly, for every resource file, gulp-transifex will check on the server for the languages and will start going to every file in each language and copy it in the local translation folder: options.local_path

var transifex = require('transifex').createClient(options)
var gulp = require('gulp')

gulp.task('downstream', function(){
    gulp.src('path/to/source/language/*')
        .pipe(transifex.pullResource())
})

Chaining Tasks with gulp-transifex

Since this plugins makes remote requests you have to call it asynchronously if you need the translation files in next tasks, just return the stream:

var transifex = require('transifex').createClient(options)
var gulp = require('gulp')

gulp.task('downstream', function(){
    return gulp.src('path/to/source/language/*')
        .pipe(transifex.pullResource())
});

gulp.task('requireTransifexFiles', ['downstream'], function () {
    ...
});

Other methods exposed

There are other methods exposed that doesn't return streams but accepts callbacks:

###resources()

Gets an array of resources in the project

var transifex = require('transifex').createClient(options)

transifex.resources(function(data){
    ...
})

###languages()

Gets an array of language codes in the project

var transifex = require('transifex').createClient(options)

transifex.languages(function (data){
    ...
})

TODO

  • ~~Add local modifications check. If there's no local modifications, don't bother check the file in transifex~~
  • Add updates check in translation files. If there ain't new translation why download the file.
  • Better division of concerns (Modularize further, separate transform function from stream declarations)