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-fill-pot-po

v4.0.0

Published

Create pre-filled po files using existing po files with pot file via gulp

Downloads

115

Readme

GitHub release (latest SemVer) NPM version

Build Status Coverall Coverage Status Dependencies Status Downloads

Gulp wrapper for fill-pot-po. Generates pre-filled PO files from POT file, using source PO files.

Based on the POT filename or set options, it looks for source PO files. For each PO file, it will create a new one, based on the contents of the POT file. The source PO file is used to fill in the matching translated strings.

For more information, details and all options, see documentation of fill-pot-po.

This package now supports both ESM and CommonJS 🎉

Install

npm install --save-dev gulp-fill-pot-po

Example usage

Basic (ESM)

import gulp from 'gulp';
const { src, dest } = gulp;
import fillPotPo from 'gulp-fill-pot-po';

const defaultTask = () => {
  return src('src/languages/*.pot')
    .pipe(fillPotPo())
    .pipe(dest('dist/languages/'));
};

export default defaultTask;

Basic (CommonJS)

const { src, dest } = require('gulp');
const fillPotPo = require('gulp-fill-pot-po');

const defaultTask = () => {
  return src('src/languages/*.pot')
    .pipe(fillPotPo())
    .pipe(dest('dist/languages/'));
};

exports.default = defaultTask;

Continue pipe with POT files

const { src, dest } = require('gulp');
const fillPotPo = require('gulp-fill-pot-po');

const defaultTask = () => {
  return (
    src('src/languages/*.pot')
      .pipe(
        fillPotPo({
          returnPOT: true,
          writeFiles: true,
          destDir: 'dist/languages/',
        })
      )
      // Continue processing POT files
      .pipe(/* ... */)
  );
};

exports.default = defaultTask;

Use with gulp-wp-pot

This example uses gulp-wp-pot to extract all translation strings from a WordPress project and generate a POT file.

The POT file is then used to create PO files with the translated strings pre-filled from detected source PO files.

For each detected PO source file, it will generate a matching new one, based on the POT file contents and filled using the source PO file.

const { src, dest } = require('gulp');
const wpPot = require('gulp-wp-pot');
const fillPotPo = require('gulp-fill-pot-po');

const defaultTask = () => {
  return (
    src('src/**/*.php')
      // Extract all translation strings from code base
      // and generate a POT file.
      .pipe(wpPot())

      // Save POT file to disk.
      .pipe(dest('dist/language/text-domain.pot'))

      // Look for matching (prior) PO translation files (e.g. text-domain-en_EN.po)
      // and use them to fill in translated strings in the new POT content.
      .pipe(
        fillPotPo({
          srcDir: 'src/language/',
        })
      )

      // Save the new pre-filled PO files to disk (one for each source PO file).
      .pipe(dest('dist/language/'))
  );
};

exports.default = defaultTask;

fillPotPo( options )

See all available options in the fill-pot-po readme.

All options are passed to fill-pot-po, but there are a few differences:

potSources

Will be set by gulp-fill-pot-po internally.

writeFiles

The default value for writeFiles is false, because the resulting buffers will probably be .pipe( dest() )'d which writes them to disk instead.

returnPOT

boolean

Whether the plugin should return the source POT file(s) (true) or the generated PO file(s) (false).

By default, it will return the generated PO files for further processing, like .pipe( dest('./') ).

In cases where you want to continue processing the source POT files, you can set this to true. Note, that in this case you need to set writeFiles to true or no PO files will be generated and the plugin throws an error.

Default: false

Related

  • fill-pot-po - NodeJS module that does all the work
  • gulp-wp-pot - Generate POT files for WordPress projects in gulp

Extra

License

MIT © Philip van Heemstra