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

potgen

v3.0.2

Published

PotGen makes generating .pot files a straightforward process. With PotGen, you can create translation files quickly and efficiently, simplifying the localization of your projects.

Downloads

81

Readme

PotGen

npm version npm downloads Node Status Node Version GitHub issues NPM License

PotGen simplifies the generation of .pot, .po, and .mo files, allowing you to create translation files quickly and efficiently, thus facilitating the localization of your projects.

Table of Contents

Installation

To install PotGen, use npm:

npm install potgen

Additional Requirements

To create .mo files, you need to have GetText installed. If you are on Windows, you can download and install GetText from:

GetText for Windows

  • GetText V 0.14.4 here

Usage

Create Configuration File

If PotGen does not generate a pot.json file in the root of your project after installation, create it manually with the following configuration:

{
  "sourcePattern": "**/*.{php,js}",
  "destFile": "languages/${domain}.pot",
  "package": "Default Package",
  "domain": "default-domain",
  "lastTranslator": "DEFAULT TRANSLATOR",
  "bugReport": "https://default.com/bugs",
  "version": "1.0.0",
  "createPoFiles": false,
  "languages": ["es_ES", "es_PE", "ru_RU"]
}

Configure Script in package.json

Add the following scripts to your package.json file:

"scripts": {
  "pot": "node node_modules/potgen/pot.js",
  "watch": "gulp --gulpfile pogen.js default",
  "po2mo": "gulp --gulpfile pogen.js po2mo",
  "lang": "gulp --gulpfile pogen.js lang"
}

Run PotGen

Depending on the configuration of createPoFiles in pot.json:

If createPoFiles is true:

npm run pot

Expected output:

Generating .pot file...
Successfully generated .pot file: default-domain.pot ✓
Generating .po files for: es_PE
.po file generated successfully: default-domain-es_PE.po ✓
Generating .po files for: ru_RU
.po file generated successfully: default-domain-ru_RU.po ✓

If createPoFiles is false:

npm run pot

Expected output:

Generating .pot file...
Successfully generated .pot file: default-domain.pot ✓

Using Gulp

You can use the following commands to manage translation files:

gulp --gulpfile pogen.js default

or

npm run watch

This will start the monitoring process for changes in .po files:

Starting 'default'...
Watching for changes in .po files

To convert .po files to .mo:

gulp --gulpfile pogen.js po2mo

or

npm run po2mo

Expected output:

Starting 'po2mo'...
Converting .po files to .mo
Conversion completed ✓

To convert .po files for a specific language:

gulp --gulpfile pogen.js lang --lang=es_PE

or

npm run lang -- --lang=es_PE

Expected output:

Starting 'lang'...
Converting files matching es_PE.po
Files found matching es_PE.po
Conversion completed for es_PE.po ✓

Configuration

| Option | Description | Default Value | |----------------------|-----------------------------------------------------------------------------|------------------------------| | sourcePattern | Glob pattern that specifies the files to search | **/*.{php,js} | | destFile | Path and name of the destination .pot file. | languages/${domain}.pot | | package | Name of the package. | Default Package | | domain | Domain for the .pot file. | default-domain | | lastTranslator | Information about the last translator. | DEFAULT TRANSLATOR | | bugReport | URL for reporting bugs. | https://default.com/bugs | | version | Version of the translation file. | 1.0.0 | | createPoFiles | true: Generates .po files in addition to the .pot file false: Only generates the .pot file. | false | | languages | List of languages for generating .po files. You can add more as needed. | ["es_ES", "es_PE", "ru_RU"] |

Features

  • 🚀 Automatically generates .pot, .po, and .mo files for WordPress plugins and themes.
  • 💻 Supports PHP and JavaScript files.
  • ⚙️ Configurable through a simple JSON file.
  • 🔠 Handles multiple WordPress translation functions (__, _e, _n, _x).
  • ⚠️ Warns about undefined domains.
  • 🔄 Options to convert .po files to .mo and generate .po files based on configuration.

Recent Updates

Changes Implemented in Version 3.0.0

  • Generation of .po and .mo Files: PotGen can now also generate .po files and convert them to .mo, in addition to .pot files.
  • Improved Gulp Support: New Gulp commands have been added to watch for changes, convert .po files to .mo, and generate files for specific languages.
  • Configuration Update: The createPoFiles option now allows you to specify whether to generate .po files along with the .pot file.

Changes Implemented in Version 2.0.0

  • HTML Handling and Format Markers: Improved handling of HTML tags and format markers in translation strings.
  • HTML Links and Multiple Markers: Correct escaping of quotes in HTML attributes.
  • Long Texts with HTML and Apostrophes: Proper handling of apostrophes and long texts with HTML.
  • HTML Entity Decoding: Decoding of HTML entities for better readability in .pot files.

Contribution

If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request in the PotGen repository on GitHub.

Donate

If you appreciate this project and would like to support its ongoing development, you can make a donation through Ko-fi. Your support is greatly appreciated!

ko-fi

License

PotGen is licensed under the MIT License