211 lines
4.3 KiB
JavaScript
211 lines
4.3 KiB
JavaScript
/*
|
|
* grunt-wp-i18n
|
|
* https://github.com/cedaro/grunt-wp-i18n
|
|
*
|
|
* Copyright (c) 2014 Cedaro, LLC
|
|
* Licensed under the MIT license.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
module.exports = function(grunt) {
|
|
|
|
grunt.loadTasks( 'tasks' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-clean' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-copy' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
|
|
grunt.loadNpmTasks( 'grunt-contrib-nodeunit' );
|
|
|
|
grunt.config.init({
|
|
|
|
jshint: {
|
|
options: {
|
|
jshintrc: '.jshintrc'
|
|
},
|
|
all: [
|
|
'Gruntfile.js',
|
|
'tasks/*.js',
|
|
'tasks/lib/*.js'
|
|
]
|
|
},
|
|
|
|
// Before generating any new files, remove any previously-created files.
|
|
clean: {
|
|
tests: ['tmp']
|
|
},
|
|
|
|
copy: {
|
|
tests: {
|
|
files: [
|
|
{
|
|
expand: true,
|
|
cwd: 'test/fixtures',
|
|
src: ['**'],
|
|
dest: 'tmp/'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
|
|
addtextdomain: {
|
|
options: {
|
|
textdomain: 'newtextdomain'
|
|
},
|
|
add_domain: {
|
|
src: ['tmp/text-domains/add-domain.php']
|
|
},
|
|
update_domains: {
|
|
options: {
|
|
updateDomains: ['oldtextdomain', 'vendortextdomain']
|
|
},
|
|
src: ['tmp/text-domains/update-domains.php']
|
|
},
|
|
update_all_domains: {
|
|
options: {
|
|
updateDomains: true
|
|
},
|
|
src: ['tmp/text-domains/update-all-domains.php']
|
|
}
|
|
},
|
|
|
|
// Configuration to be run (and then tested).
|
|
makepot: {
|
|
basic_plugin: {
|
|
options: {
|
|
cwd: 'tmp/basic-plugin',
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
persist_timestamp: {
|
|
options: {
|
|
cwd: 'tmp/basic-plugin',
|
|
type: 'wp-plugin',
|
|
updateTimestamp: false
|
|
}
|
|
},
|
|
different_slugs: {
|
|
options: {
|
|
cwd: 'tmp/different-slugs',
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
plugin_headers: {
|
|
options: {
|
|
cwd: 'tmp/plugin-headers',
|
|
potComments: 'A new comment header.',
|
|
potHeaders: {
|
|
'report-msgid-bugs-to': 'https://github.com/cedaro/grunt-wp-i18n/issues',
|
|
'x-poedit-keywordslist': '',
|
|
'x-poedit-searchpath-0': '',
|
|
'x-poedit-searchpathexcluded-0': '',
|
|
'x-poedit-sourcecharset': ''
|
|
},
|
|
processPot: function( pot, options ) {
|
|
pot.headers['language-team'] = 'Team Name <team@example.com>';
|
|
return pot;
|
|
},
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
theme_headers: {
|
|
options: {
|
|
cwd: 'tmp/theme-headers',
|
|
processPot: function( pot, options ) {
|
|
pot.headers['language-team'] = 'Team Name <team@example.com>';
|
|
return pot;
|
|
},
|
|
type: 'wp-theme'
|
|
}
|
|
},
|
|
ignore_headers: {
|
|
options: {
|
|
cwd: 'tmp/plugin-headers',
|
|
domainPath: '.',
|
|
potFilename: 'override.pot',
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
basic_theme: {
|
|
options: {
|
|
cwd: 'tmp/basic-theme',
|
|
exclude: ['exclude/.*'],
|
|
type: 'wp-theme'
|
|
}
|
|
},
|
|
plugin_include: {
|
|
options: {
|
|
cwd: 'tmp/plugin-include',
|
|
include: ['include/.*'],
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
common_pot_headers: {
|
|
options: {
|
|
cwd: 'tmp/common-pot-headers',
|
|
potHeaders: {
|
|
poedit: true
|
|
|
|
},
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
customize_common_pot_headers: {
|
|
options: {
|
|
cwd: 'tmp/common-pot-headers',
|
|
potFilename: 'custom-pot-headers.pot',
|
|
potHeaders: {
|
|
'x-poedit-country': 'Spain',
|
|
poedit: true,
|
|
language: 'es',
|
|
'x-poedit-keywordslist': '',
|
|
'Project-Id-Version': 'Custom Value' // Testing case.
|
|
},
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
translator_comments: {
|
|
options: {
|
|
cwd: 'tmp/translator-comments',
|
|
type: 'wp-plugin'
|
|
}
|
|
},
|
|
|
|
msg_merge_merging: {
|
|
options: {
|
|
cwd: 'tmp/msg-merge',
|
|
updatePoFiles: true
|
|
}
|
|
},
|
|
|
|
msg_merge_no_merging: {
|
|
options: {
|
|
cwd: 'tmp/msg-merge-no-merge',
|
|
updatePoFiles: false
|
|
}
|
|
},
|
|
|
|
msg_merge_theme: {
|
|
options: {
|
|
type: 'wp-theme',
|
|
cwd: 'tmp/msg-merge-theme',
|
|
updatePoFiles: true
|
|
}
|
|
}
|
|
},
|
|
|
|
// Unit tests.
|
|
nodeunit: {
|
|
tests: ['test/*_test.js'],
|
|
}
|
|
|
|
});
|
|
|
|
// Register default task.
|
|
grunt.registerTask( 'default', ['jshint', 'test']);
|
|
|
|
// Whenever the "test" task is run, first clean the "tmp" dir,
|
|
// copy the "fixtures", then run this plugin's task(s), then test the result.
|
|
grunt.registerTask( 'test', ['clean', 'copy', 'makepot', 'addtextdomain', 'nodeunit']);
|
|
|
|
};
|