Use early return in makepot.js

This commit is contained in:
Jan Jakes
2021-12-07 10:13:25 +01:00
committed by Veljko V
parent a144ec4d39
commit f6e1c0c101

View File

@@ -14,74 +14,75 @@ module.exports = function (grunt) {
if (base_path === undefined || grunt.file.exists(base_path) === false) { if (base_path === undefined || grunt.file.exists(base_path) === false) {
grunt.fail.fatal("Missing --base_path argument"); grunt.fail.fatal("Missing --base_path argument");
} else { return;
// configuration. }
grunt.initConfig({
makepot: { // configuration.
target: { grunt.initConfig({
options: { makepot: {
cwd: '.', // base path where to look for translatable strings target: {
domainPath: 'lang', // where to save the .pot options: {
exclude: [ cwd: '.', // base path where to look for translatable strings
'\.mp_svn/.*', domainPath: 'lang', // where to save the .pot
'assets/.*', exclude: [
'lang/.*', '\.mp_svn/.*',
'node_modules/.*', 'assets/.*',
'plugin_repository/.*', 'lang/.*',
'tasks/.*', 'node_modules/.*',
'tests/.*', 'plugin_repository/.*',
'vendor/.*' 'tasks/.*',
], 'tests/.*',
mainFile: 'index.php', // Main project file. 'vendor/.*'
potFilename: 'mailpoet.pot', // Name of the POT file. ],
potHeaders: { mainFile: 'index.php', // Main project file.
poedit: true, // Includes common Poedit headers. potFilename: 'mailpoet.pot', // Name of the POT file.
'x-poedit-keywordslist': true // Include a list of all possible gettext functions. potHeaders: {
}, poedit: true, // Includes common Poedit headers.
type: 'wp-plugin', // Type of project (wp-plugin or wp-theme). 'x-poedit-keywordslist': true // Include a list of all possible gettext functions.
updateTimestamp: true, // Whether the POT-Creation-Date should be updated without other changes. },
processPot: function (pot, options) { type: 'wp-plugin', // Type of project (wp-plugin or wp-theme).
pot.headers['report-msgid-bugs-to'] = 'http://support.mailpoet.com/'; updateTimestamp: true, // Whether the POT-Creation-Date should be updated without other changes.
pot.headers['last-translator'] = 'MailPoet i18n (https://www.transifex.com/organization/wysija)'; processPot: function (pot, options) {
pot.headers['language-team'] = 'MailPoet i18n <https://www.transifex.com/organization/wysija>'; pot.headers['report-msgid-bugs-to'] = 'http://support.mailpoet.com/';
pot.headers['language'] = 'en_US'; pot.headers['last-translator'] = 'MailPoet i18n (https://www.transifex.com/organization/wysija)';
return pot; pot.headers['language-team'] = 'MailPoet i18n <https://www.transifex.com/organization/wysija>';
} pot.headers['language'] = 'en_US';
return pot;
} }
} }
},
shell: {
options: {
stdout: true,
stderr: true
},
txpush: {
command: 'tx push -s' // push the resources (requires an initial resource set on TX website)
},
txpull: {
command: 'tx pull -a -f' // pull the .po files
}
} }
}); },
shell: {
options: {
stdout: true,
stderr: true
},
txpush: {
command: 'tx push -s' // push the resources (requires an initial resource set on TX website)
},
txpull: {
command: 'tx pull -a -f' // pull the .po files
}
}
});
grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks( 'grunt-wp-i18n' ); grunt.loadNpmTasks( 'grunt-wp-i18n' );
// set base // set base
grunt.file.setBase(base_path); grunt.file.setBase(base_path);
// Register tasks // Register tasks
grunt.registerTask('default', function () { grunt.registerTask('default', function () {
grunt.log.writeln(" x-----------------------------x"); grunt.log.writeln(" x-----------------------------x");
grunt.log.writeln(" | MailPoet i18n |"); grunt.log.writeln(" | MailPoet i18n |");
grunt.log.writeln(" x-----------------------------x"); grunt.log.writeln(" x-----------------------------x");
grunt.log.writeln(" \n Commands: \n"); grunt.log.writeln(" \n Commands: \n");
grunt.log.writeln(" grunt makepot = Generates the .pot file"); grunt.log.writeln(" grunt makepot = Generates the .pot file");
grunt.log.writeln(" grunt pushpot = Pushes the .pot file to Transifex"); grunt.log.writeln(" grunt pushpot = Pushes the .pot file to Transifex");
grunt.log.writeln(" grunt update = Runs 'makepot' then 'pushpot'"); grunt.log.writeln(" grunt update = Runs 'makepot' then 'pushpot'");
}); });
grunt.registerTask('pushpot', ['shell:txpush']); grunt.registerTask('pushpot', ['shell:txpush']);
grunt.registerTask('update', ['makepot', 'shell:txpush']); grunt.registerTask('update', ['makepot', 'shell:txpush']);
}
}; };