Skip to content

Commit c6fc9a7

Browse files
committed
Remove support for a custom PHP tools path.
Trying to maintain support for a custom tools path was becoming a little messy. Searching GitHub didn't reveal any projects using the option, aside from a few that had the default value copied from old documentation.
1 parent 2b1c7cb commit c6fc9a7

File tree

4 files changed

+8
-69
lines changed

4 files changed

+8
-69
lines changed

docs/addtextdomain.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ In your project's Gruntfile, add a section named `addtextdomain` to the data obj
1515
grunt.initConfig({
1616
addtextdomain: {
1717
options: {
18-
i18nToolsPath: '', // Path to the i18n tools directory.
1918
textdomain: '', // Project text domain.
2019
updateDomains: [] // List of text domains to replace.
2120
},
@@ -29,11 +28,6 @@ grunt.initConfig({
2928

3029
## Options
3130

32-
### options.i18nToolsPath
33-
Type: `String`
34-
35-
Path to a local copy of the WordPress i18n tools. May be relative to the project or an absolute path. Defaults to a bundled version of the i18n tools.
36-
3731
### options.textdomain
3832
Type: `String`
3933
Default value: `''`

tasks/add-textdomain.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module.exports = function( grunt ) {
1212

1313
var async = require( 'async' ),
1414
path = require( 'path' ),
15-
localConfig = require( './lib/util' ).init( grunt ).getLocalConfig(),
1615
wp = require( './lib/wordpress' ).init( grunt );
1716

1817
/**
@@ -22,12 +21,10 @@ module.exports = function( grunt ) {
2221
*/
2322
grunt.registerMultiTask( 'addtextdomain', 'Add the text domain to gettext functions.', function() {
2423
var done = this.async(),
25-
defaultI18nToolsPath = path.resolve( __dirname, '../vendor/wp-i18n-tools/' ),
2624
files = [],
2725
cmdArgs, o;
2826

2927
o = this.options({
30-
i18nToolsPath: defaultI18nToolsPath,
3128
textdomain: '',
3229
updateDomains: []
3330
});
@@ -38,39 +35,23 @@ module.exports = function( grunt ) {
3835
o.textdomain = wp.getHeader( 'Text Domain' ) || wp.slugify();
3936
}
4037

41-
o.i18nToolsPath = localConfig.i18nToolsPath || o.i18nToolsPath;
42-
43-
// Make sure the add-textdomain.php script exists.
44-
o.addTextdomainScript = path.join( o.i18nToolsPath, 'add-textdomain.php' );
45-
if ( ! grunt.file.exists( o.addTextdomainScript ) ) {
46-
grunt.fatal( 'add-textdomain.php could not be found in ' + o.i18nToolsPath );
47-
}
48-
4938
if ( true === o.updateDomains ) {
5039
o.updateDomains = ['all'];
5140
}
5241

5342
// Build the list of CLI args.
5443
cmdArgs = [
55-
o.addTextdomainScript,
44+
path.resolve( __dirname, '../vendor/wp-i18n-tools/grunt-add-textdomain.php' ),
5645
'-i',
5746
o.textdomain,
58-
''
47+
'',
48+
o.updateDomains.join( ',' )
5949
];
6050

6151
if ( grunt.option( 'dry-run' ) ) {
6252
cmdArgs[1] = '';
6353
}
6454

65-
// Only add custom CLI args if using the bundled tools.
66-
if ( defaultI18nToolsPath === o.i18nToolsPath ) {
67-
// Use the custom CLI script that extends add-textdomain.php.
68-
o.addTextdomainScript = path.join( o.i18nToolsPath, 'grunt-add-textdomain.php' );
69-
70-
cmdArgs[0] = o.addTextdomainScript;
71-
cmdArgs.push( o.updateDomains.join( ',' ) );
72-
}
73-
7455
this.files.forEach(function( f ) {
7556
var filtered = f.src.filter(function( filepath ) {
7657
// Warn on and remove invalid source files (if nonull was set).

tasks/lib/util.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,6 @@ exports.init = function( grunt ) {
6060
return originalHash === compareHash;
6161
};
6262

63-
/**
64-
* Load local config options from config.json in the project root.
65-
*
66-
* The config.json may contain sensitive data and should not be included in
67-
* version control.
68-
*
69-
* @return {Object}
70-
*/
71-
exports.getLocalConfig = function() {
72-
var localConfig = {};
73-
74-
if ( grunt.file.exists( 'config.json' ) ) {
75-
localConfig = grunt.file.readJSON( 'config.json' );
76-
}
77-
78-
return localConfig;
79-
};
80-
8163
/**
8264
* Merge custom POT headers.
8365
*

tasks/makepot.js

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = function( grunt ) {
1515
path = require( 'path' ),
1616
pkg = require( '../package.json' ),
1717
util = require( './lib/util' ).init( grunt ),
18-
localConfig = util.getLocalConfig(),
1918
wp = require( './lib/wordpress' ).init( grunt),
2019
msgMerge = require( './lib/msgmerge' ).init( grunt ),
2120
async = require( 'async' );
@@ -33,7 +32,6 @@ module.exports = function( grunt ) {
3332
*/
3433
grunt.registerMultiTask( 'makepot', 'Generate a POT file for translating strings.', function() {
3534
var done = this.async(),
36-
defaultI18nToolsPath = path.resolve( __dirname, '../vendor/wp-i18n-tools/' ),
3735
gruntBase = process.cwd(),
3836
cmdArgs, o, originalPot;
3937

@@ -42,7 +40,6 @@ module.exports = function( grunt ) {
4240
domainPath: '',
4341
exclude: [],
4442
include: [],
45-
i18nToolsPath: defaultI18nToolsPath,
4643
mainFile: '',
4744
potComments: '',
4845
potFilename: '',
@@ -74,15 +71,8 @@ module.exports = function( grunt ) {
7471
}
7572

7673
o.domainPath = _.ltrim( o.domainPath, [ '/', '\\' ] );
77-
o.i18nToolsPath = localConfig.i18nToolsPath || o.i18nToolsPath;
7874
o.potFile = path.join( o.cwd, o.domainPath, o.potFilename );
7975

80-
// Make sure the makepot.php script exists.
81-
o.makepotScript = path.join( o.i18nToolsPath, 'makepot.php' );
82-
if ( ! grunt.file.exists( o.makepotScript ) ) {
83-
grunt.fatal( 'makepot.php could not be found in ' + o.i18nToolsPath );
84-
}
85-
8676
// Create the domain path directory if it doesn't exist.
8777
grunt.file.mkdir( path.resolve( o.cwd, o.domainPath ) );
8878

@@ -94,23 +84,15 @@ module.exports = function( grunt ) {
9484

9585
// Build the list of CLI args.
9686
cmdArgs = [
97-
o.makepotScript,
87+
path.resolve( __dirname, '../vendor/wp-i18n-tools/grunt-makepot.php' ),
9888
o.type,
9989
o.cwd,
100-
o.potFile
90+
o.potFile,
91+
o.mainFile.split( '.' ).shift(),
92+
o.exclude.join( ',' ),
93+
o.include.join( ',' )
10194
];
10295

103-
if ( defaultI18nToolsPath === o.i18nToolsPath ) {
104-
// Use the custom CLI script that extends makepot.php.
105-
o.makepotScript = path.join( o.i18nToolsPath, 'grunt-makepot.php' );
106-
107-
// Only add custom CLI args if using the bundled tools.
108-
cmdArgs[0] = o.makepotScript;
109-
cmdArgs.push( o.mainFile.split( '.' ).shift() );
110-
cmdArgs.push( o.exclude.join( ',' ) );
111-
cmdArgs.push( o.include.join( ',' ) );
112-
}
113-
11496
// Parse the existing POT file to compare for changes.
11597
if ( ! o.updateTimestamp && grunt.file.exists( o.potFile ) ) {
11698
originalPot = gettext.po.parse( grunt.file.read( o.potFile ) );

0 commit comments

Comments
 (0)