|
| 1 | +module.exports = function(grunt) { |
| 2 | + |
| 3 | +// Load multiple grunt tasks using globbing patterns |
| 4 | +require('load-grunt-tasks')(grunt); |
| 5 | + |
| 6 | +// Project configuration. |
| 7 | +grunt.initConfig({ |
| 8 | + pkg: grunt.file.readJSON('package.json'), |
| 9 | + |
| 10 | + makepot: { |
| 11 | + target: { |
| 12 | + options: { |
| 13 | + domainPath: 'languages/', // Where to save the POT file. |
| 14 | + exclude: ['build/.*'], |
| 15 | + mainFile: 'auto-load-next-post.php', // Main project file. |
| 16 | + potComments: 'Auto Load Next Post Copyright (c) {{year}}', // The copyright at the beginning of the POT file. |
| 17 | + potFilename: 'auto-load-next-post.pot', // Name of the POT file. |
| 18 | + type: 'wp-plugin', // Type of project. |
| 19 | + updateTimestamp: true, // Whether the POT-Creation-Date should be updated without other changes. |
| 20 | + processPot: function( pot, options ) { |
| 21 | + pot.headers['report-msgid-bugs-to'] = 'https://github.com/seb86/Auto-Load-Next-Post/issues\n'; |
| 22 | + pot.headers['plural-forms'] = 'nplurals=2; plural=n != 1;\n'; |
| 23 | + pot.headers['last-translator'] = 'Auto Load Next Post <mailme@sebastiendumont.com>\n'; |
| 24 | + pot.headers['language-team'] = 'WP-Translations <wpt@wp-translations.org>\n'; |
| 25 | + pot.headers['x-poedit-basepath'] = '..\n'; |
| 26 | + pot.headers['x-poedit-language'] = 'English\n'; |
| 27 | + pot.headers['x-poedit-country'] = 'UNITED STATES\n'; |
| 28 | + pot.headers['x-poedit-sourcecharset'] = 'utf-8\n'; |
| 29 | + pot.headers['x-poedit-searchpath-0'] = '.\n'; |
| 30 | + pot.headers['x-poedit-keywordslist'] = '__;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n'; |
| 31 | + pot.headers['x-textdomain-support'] = 'yes\n'; |
| 32 | + return pot; |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + }, |
| 37 | + |
| 38 | + exec: { |
| 39 | + npmUpdate: { |
| 40 | + command: 'npm update' |
| 41 | + }, |
| 42 | + txpull: { // Pull Transifex translation - grunt exec:txpull |
| 43 | + cmd: 'tx pull -a --minimum-perc=60' // Change the percentage with --minimum-perc=yourvalue |
| 44 | + }, |
| 45 | + txpush_s: { // Push pot to Transifex - grunt exec:txpush_s |
| 46 | + cmd: 'tx push -s' |
| 47 | + }, |
| 48 | + }, |
| 49 | + |
| 50 | + dirs: { |
| 51 | + lang: 'languages', |
| 52 | + }, |
| 53 | + |
| 54 | + potomo: { |
| 55 | + dist: { |
| 56 | + options: { |
| 57 | + poDel: false // Set to true if you want to erase the .po |
| 58 | + }, |
| 59 | + files: [{ |
| 60 | + expand: true, |
| 61 | + cwd: '<%= dirs.lang %>', |
| 62 | + src: ['*.po'], |
| 63 | + dest: '<%= dirs.lang %>', |
| 64 | + ext: '.mo', |
| 65 | + nonull: true |
| 66 | + }] |
| 67 | + } |
| 68 | + }, |
| 69 | + |
| 70 | +}); |
| 71 | + |
| 72 | +// Default task. - grunt makepot |
| 73 | +grunt.registerTask( 'default', 'makepot' ); |
| 74 | + |
| 75 | +// Makepot and push it on Transifex task(s). |
| 76 | +grunt.registerTask( 'txpush', [ 'makepot', 'exec:txpush_s' ] ); |
| 77 | + |
| 78 | +// Pull from Transifex and create .mo task(s). |
| 79 | +grunt.registerTask( 'txpull', [ 'exec:txpull', 'potomo' ] ); |
| 80 | + |
| 81 | +}; |
0 commit comments