Grunt plug-in to compile .po files into binary .mo files with msgfmt.
- This plugin requires Grunt
~0.4.5
- GNU gettext installed and in your PATH. Installation instructions: Mac, Windows and Linux
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-potomo --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks( 'grunt-potomo' );
Run this task with the grunt potomo
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Type: Boolean
Default: false
Whether the PO
file(s) used from source should be deleted or remove after the creation of MO
file(s).
grunt.initConfig({
potomo: { // Task
dist: { // Target
options: { // Target options
poDel: true
},
files: { // Dictionary of files
'en_GB.mo': 'en_GB.po', // 'destination': 'source'
'ne_NP.mo': 'ne_NP.po'
}
},
dev: { // Another target
options: { // Target options
poDel: false
},
files: {
'dest/languages': [ 'en_GB.po', 'ne_NP.po' ]
}
}
}
});
grunt.loadNpmTasks( 'grunt-potomo' );
grunt.registerTask( 'default', ['potomo' ]);
grunt.initConfig({
potomo: {
dist: {
files: {
'ne_NP.mo': 'ne_NP.po'
}
}
}
});
grunt.initConfig({
potomo: {
dist: {
options: {
poDel: true
}
files: {
'ne_NP.mo': 'ne_NP.po'
}
}
}
});
You can specify multiple destination: source
items in files
.
grunt.initConfig({
potomo: {
dist: {
files: {
'en_GB.mo': 'en_GB.po',
'ne_NP.mo': 'ne_NP.po'
}
}
}
});
Instead of naming all files you want to compile, you can use the expand
property allowing you to specify a directory. More information available in the grunt docs - Building the files object dynamically
.
grunt.initConfig({
dirs: {
lang: 'language',
},
potomo: {
dist: {
options: {
poDel: false
},
files: [{
expand: true,
cwd: '<%= dirs.lang %>/po',
src: ['*.po'],
dest: '<%= dirs.lang %>/mo',
ext: '.mo',
nonull: true
}]
}
}
});
Copyright (c) 2016 Shiva Poudel
Licensed under the MIT license:
http://shivapoudel.mit-license.org/