Used to enable updates for plugins and themes distributed via WP Plugin Update Server.
Project Category: WordPress Library
-
Grunt WP plugin tasks
(formerly barely known as olib-dev)
Dev libraries that might or might not be useful for WordPress plugins developers.
See the sister project magicoli/grunt-translation-tasks to use in a generic project (using gettext insttead of WP-specific framework).
Provides
- makereadmetxt: Builds or updates the WordPress standard plugin readme.txt compiling and reformatting README.md, INSTALLATION.md, FAQ.md, CHANGELOG.md.
- i18n: Prepares internationalization assets, updating text domains, generating POT, and converting PO files to MO.
- makemo: Converts PO files to MO using WP CLI.
Installation
- Clone the repository into your plugin’s subfolder (e.g., at dev/grunt-wp-plugin-tasks).
- Exclude this subfolder from distribution (e.g., add dev/grunt-wp-plugin-tasks to your .distignore).
- Add the following workspace configuration to your plugin’s package.json:
"workspaces": { "packages": [ "dev/grunt-wp-plugin-tasks" ] }
- Run "npm install" to install dependencies.
- In your plugin’s Gruntfile.js
- Define your plugin slug name slug (e.g. ‘my-plugin’)
- Load the custom tasks with:
// ...existing code... const pluginName = 'YOURPLUGINSLUG'; // replace with your slug require('./dev/grunt-wp-plugin-tasks/grunt-wp-plugin-tasks.js')(grunt, pluginName); // ...existing code...
- Run "grunt" or invoke specific tasks (e.g., "grunt i18n") as needed.
-
grunt-translation-tasks
Grunt tasks for managing translations and internationalization in PHP projects using standard gettext tools.
Features
- makepot (
xgettext
): Extracts translatable strings from PHP files into POT template - msgmerge: Updates existing PO files with new strings from POT file
- makemo (
msgfmt
): Compiles PO files to binary MO files - i18n: Complete workflow – extract, merge, and compile translations
Installation
- Clone this repository into your project’s dev folder:
git submodule add https://github.com/magicoli/grunt-translation-tasks dev/grunt-translation-tasks
- Add workspace configuration to your project’s package.json:
"workspaces": { "packages": [ "dev/grunt-translation-tasks" ] }
- Install dependencies:
npm install
- Load the tasks in your Gruntfile.js:
// Load translation tasks require('./dev/grunt-translation-tasks/grunt-translation-tasks.js')(grunt);
Usage
Available Tasks
grunt makepot
– Extract strings to POT filegrunt msgmerge
– Update PO files with new POT contentgrunt makemo
– Compile PO files to MO filesgrunt i18n
– Run complete translation workflow
Directory Structure
Uses standard gettext directory structure:
locale/ ├── project-name.pot # Template file ├── fr_FR/ │ └── LC_MESSAGES/ │ ├── project-name.po # French translations │ └── project-name.mo # Compiled binary ├── nl_NL/ │ └── LC_MESSAGES/ │ ├── project-name.po # Dutch translations │ └── project-name.mo # Compiled binary └── ...
Supported Translation Functions
Extracts strings from these PHP functions:
_()
,__()
– Basic translation_e()
– Echo translation_c()
,_x()
,_ex()
– Context translation_n()
,_nx()
– Plural translationesc_attr__()
,esc_html__()
– Escaped translationesc_attr_e()
,esc_html_e()
– Escaped echo translation
Requirements
- Node.js >= 14.0.0
- Grunt CLI
- Standard gettext tools (
xgettext
,msgmerge
,msgfmt
)
Configuration
The project name is automatically detected from your
package.json
. You can customize paths and options by modifying the task configuration in your Gruntfile.js after loading the tasks. - makepot (