Skip to content

Commit 89199df

Browse files
committed
[godaddy-wordpress#92] Post-process PO files, add grunt build task
1 parent 041c8aa commit 89199df

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

Gruntfile.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ module.exports = function( grunt ) {
5454
grunt.initConfig( gruntConfig );
5555

5656
// Load custom tasks
57-
// Disabled, because there are no custom tasks yet. Enable when needed :)
58-
// grunt.loadTasks( 'grunt/tasks/' );
57+
grunt.loadTasks( 'grunt/tasks/' );
5958

6059
// Register update_translations task
6160
grunt.registerTask( 'update_translations', [
@@ -65,12 +64,22 @@ module.exports = function( grunt ) {
6564
'potomo'
6665
] );
6766

67+
// Register build task
68+
grunt.registerTask( 'build', [
69+
'coffee',
70+
'uglify',
71+
'sass',
72+
'update_translations',
73+
'clean'
74+
] );
75+
6876
// Register default task
6977
grunt.registerTask( 'default', [
7078
'coffee',
7179
'uglify',
7280
'sass',
7381
'makepot',
82+
'shell:tx_push',
7483
'clean'
7584
] );
7685

grunt/configs/makepot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ module.exports = function( grunt ) {
1212
cwd: 'woocommerce',
1313
domainPath: 'i18n/languages',
1414
exclude: [],
15-
potFilename: 'wc-plugin-framework.pot',
15+
potFilename: '<%= pkg.name %>.pot',
1616
mainFile: 'index.php',
1717
potHeaders: {
1818
'report-msgid-bugs-to': 'https://support.woothemes.com/hc/',
19-
'project-id-version': 'WooCommerce Plugin Framework <%= pkg.version %>',
19+
'project-id-version': '<%= pkg.title %> <%= pkg.version %>',
2020
},
2121
processPot: function( pot ) {
2222
delete pot.headers['x-generator'];

grunt/tasks/parsepo.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* jshint node:true */
2+
module.exports = function( grunt ) {
3+
'use strict';
4+
5+
var fs = require('fs'),
6+
gp = require('gettext-parser'),
7+
util = grunt.option( 'util' );
8+
9+
// Parse and adjust PO headers.
10+
grunt.registerTask( 'parsepo', 'Custom parse PO task.', function () {
11+
12+
var files = grunt.file.expand( grunt.config( 'dirs.lang' ) + '/*.po' );
13+
14+
if ( ! files.length ) {
15+
return;
16+
}
17+
18+
files.forEach( function (file) {
19+
20+
var input = fs.readFileSync( file ),
21+
po = gp.po.parse( input );
22+
23+
// Set PO file headers to reflect the current version number.
24+
po.headers['project-id-version'] = grunt.config( 'pkg.title' ) + ' ' + grunt.config( 'pkg.version' );
25+
26+
fs.writeFileSync( file, gp.po.compile( po ) );
27+
} );
28+
29+
} );
30+
31+
};

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "wc-plugin-framework",
33
"version": "4.0.0",
4+
"title": "WooCommerce Plugin Framework",
45
"author": "SkyVerge Team",
56
"homepage": "https://github.com/skyverge/wc-plugin-framework#readme",
67
"repository": {
@@ -15,6 +16,7 @@
1516
"node": ">= 0.10.0"
1617
},
1718
"devDependencies": {
19+
"gettext-parser": "^1.1.1",
1820
"grunt": "~0.4.5",
1921
"grunt-contrib-clean": "~0.6.0",
2022
"grunt-contrib-coffee": "~0.13.0",
@@ -24,6 +26,7 @@
2426
"grunt-notify": "~0.4.1",
2527
"grunt-potomo": "^3.3.3",
2628
"grunt-shell": "^1.1.2",
29+
"grunt-text-replace": "^0.4.0",
2730
"grunt-wp-i18n": "^0.5.2",
2831
"load-grunt-tasks": "~3.2.0",
2932
"time-grunt": "~1.2.1",

0 commit comments

Comments
 (0)