added grunt i18n tasks

This commit is contained in:
claudiosmweb 2014-08-01 09:53:31 -03:00
parent 72fff668d4
commit 0dc14373ee
2 changed files with 75 additions and 18 deletions

View File

@ -1,5 +1,5 @@
/* jshint node:true */
module.exports = function( grunt ){
module.exports = function( grunt ) {
'use strict';
grunt.initConfig({
@ -102,19 +102,77 @@ module.exports = function( grunt ){
}
},
makepot: {
options: {
type: 'wp-plugin',
domainPath: 'i18n/languages',
potHeaders: {
'report-msgid-bugs-to': 'https://github.com/woothemes/woocommerce/issues',
'language-team': 'LANGUAGE <EMAIL@ADDRESS>'
}
},
frontend: {
options: {
potFilename: 'woocommerce.pot',
exclude: [
'includes/admin/.*',
'apigen/.*'
],
processPot: function( pot, options ) {
pot.headers['project-id-version'] += ' Frontend';
return pot;
}
}
},
admin: {
options: {
potFilename: 'woocommerce-admin.pot',
exclude: [
'^(?!includes\/admin).*'
],
processPot: function( pot, options ) {
pot.headers['project-id-version'] += ' Admin';
return pot;
}
}
}
},
checktextdomain: {
options:{
text_domain: 'woocommerce',
keywords: [
'__:1,2d',
'_e:1,2d',
'_x:1,2c,3d',
'esc_html__:1,2d',
'esc_html_e:1,2d',
'esc_html_x:1,2c,3d',
'esc_attr__:1,2d',
'esc_attr_e:1,2d',
'esc_attr_x:1,2c,3d',
'_ex:1,2c,3d',
'_n:1,2,4d',
'_nx:1,2,4c,5d',
'_n_noop:1,2,3d',
'_nx_noop:1,2,3c,4d'
],
},
files: {
src: [
'**/*.php', // Include all files
'!apigen/**', // Exclude apigen/
'!node_modules/**' // Exclude node_modules/
],
expand: true,
},
},
shell: {
options: {
stdout: true,
stderr: true
},
generatepot: {
command: [
'cd i18n/makepot/',
'sed -i "" "s/exit( \'Locked\' );/\\/\\/exit( \'Locked\' );/g" index.php',
'php index.php generate',
'sed -i "" "s/\\/\\/exit( \'Locked\' );/exit( \'Locked\' );/g" index.php',
].join( '&&' )
},
apigen: {
command: [
'cd apigen/',
@ -161,6 +219,8 @@ module.exports = function( grunt ){
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.loadNpmTasks( 'grunt-checktextdomain' );
// Register tasks
grunt.registerTask( 'default', [
@ -169,11 +229,6 @@ module.exports = function( grunt ){
'uglify'
]);
// Just an alias for pot file generation
grunt.registerTask( 'pot', [
'shell:generatepot'
]);
grunt.registerTask( 'docs', [
'clean:apigen',
'shell:apigen'
@ -181,7 +236,7 @@ module.exports = function( grunt ){
grunt.registerTask( 'dev', [
'default',
'pot'
'makepot'
]);
grunt.registerTask( 'deploy', [

View File

@ -4,8 +4,8 @@
"version": "2.2.0",
"homepage": "http://www.woothemes.com/woocommerce/",
"repository": {
"type" : "git",
"url" : "https://github.com/woothemes/woocommerce.git"
"type": "git",
"url": "https://github.com/woothemes/woocommerce.git"
},
"main": "Gruntfile.js",
"devDependencies": {
@ -16,7 +16,9 @@
"grunt-shell": "~0.7.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-clean": "~0.6.0"
"grunt-contrib-clean": "~0.6.0",
"grunt-checktextdomain": "^0.1.1",
"grunt-wp-i18n": "^0.4.6"
},
"engines": {
"node": ">=0.8.0",