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

v1.1.2

Published

Importing Phraseapp translations as a Gulp task

Downloads

264

Readme

gulp-phraseapp

Importing Phraseapp translations as a Gulp task. Can run up to 2 parallel up- and downloads (limited by Phraseapp rate-limiting).

Uses the new Phraseapp API v2, which requires you to generate an Access Token and copy your Project ID from the project overview.

npm install gulp-phraseapp --save-dev
var phraseapp = require('gulp-phraseapp');

// optional, credentials can also be passed to download/upload functions
phraseapp.init({accessToken: 'your_token', projectID: 'project_id'})

gulp.task('phraseapp:import', function () {
  phraseapp.download().pipe(gulp.dest('./locales'));
});

gulp.task('phraseapp:export', function () {
  gulp.dest('./locales').pipe(phraseapp.upload());
});

Documentation

init

Initialize with authentication/project parameters so that they don't have to be passed to every function individually.

Arguments

  • accessToken the access token used by the Phraseapp API to authenticate
  • projectID the project ID to identify your project

download

The download function creates a stream that downloads all translations in your project as JSON files and can be piped into e.g. gulp.dest to save the translation files.

Example:

phraseapp.download().pipe(gulp.dest('./locales'));

Example using a base translation:

phraseapp.download({base: 'en'}).pipe(gulp.dest('./locales'));

Arguments

  • accessToken the access token used by the Phraseapp API to authenticate
  • projectID the project ID to identify your project
  • base (optional) if you specify this, missing keys in translation files will be filled with the translation of the specified locale
  • file_format (optional) locale file format (nested_json / simple_json). Defaults to nested_json.

upload

The upload function exposes a stream that can be piped onto to upload translation files.

Since Phraseapp requires you to keep track of "locale IDs", this method will make another call to the Phraseapp API requesting the IDs for the locale files you piped into upload.

This requires your file names to follow the pattern of {locale_name}.json, e.g. en.json, de.json, fr.json. (This is also what the download function will generate).

If you want to manually specify all IDs and locale files yourself, you may pass a file option into phraseapp.upload. (see below)

Example with automagic ID fetching:

gulp.dest('./locales').pipe(phraseapp.upload());

Example without automagic ID fetching:

phraseapp.upload({
  files: {
    '2b2d778950597cdd62ab1ca89cb96817': './locales/es.json',
    'f3eee97d1a015bfb721cfe8e7bc9acaf': './locales/fr.json'
  }
});

Arguments

  • accessToken the access token used by the Phraseapp API to authenticate
  • projectID the project ID to identify your project
  • files (optional) a key-value map where the key is the locale ID and the file is the filename to upload, if you follow the {name}.json pattern you can pipe into upload instead of this
  • file_format (optional) locale file format (nested_json / simple_json). Defaults to nested_json.