Closed grappler closed 10 years ago
Updating headers should be possible, but I'll have to find some time to add options to define those.
I just pushed a commit that should give you complete access to the POT file after it's been generated and let you modify it any way you want using a callback. As an example for changing that header, you can add an option like this:
makepot: {
target: {
options: {
processPot: function( pot, options ) {
pot.headers['report-msgid-bugs-to'] = 'http://wordpress.org/support/plugin/flowplayer5';
return pot;
}
}
}
}
It's not totally config-based, but should give people much more control over the output. Let me know if that's helpful.
would this also work for adding header items that the i18n tools library don’t add themselves?
@defries Yep, that's the idea. Just add or overwrite keys in that headers
object and they should be saved back to the POT file.
Cool! Will check it out.
I've tried this – by updating the grunt-wp-i18n Gruntfile.js file –, but couldn't get it to work. This is what my Gruntfile.js contains:
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
makepot: {
target: {
options: {
domainPath: '/languages',
potFilename: 'wordpress-seo.pot',
processPot: function( pot, options ) {
pot.headers['plural-forms'] = 'nplurals=2; plural=n != 1;\n"';
pot.header['language-team'] = 'Yoast Translate <translations@yoast.com>\n';
return pot;
},
type: 'wp-plugin'
}
}
}
});
None of the overrides are actually processed.
Sorry, I should have been more clear. That commit hasn't been released yet, so you need to specify the dev version in your package.json to test it out. Change the package version to the following URL and run npm install
: git://github.com/blazersix/grunt-wp-i18n.git#develop
Hmm, couldn't make that work either. It's not actually updating to the develop branch when I put this in my package.json
and run npm install
:
"devDependencies": {
"grunt": "~0.4.1",
"grunt-wp-i18n": "git://github.com/blazersix/grunt-wp-i18n.git#develop"
},
It might be the cache. Try running npm cache clean
before doing npm install
.
Cleared cache and although that make the npm install
script do more, it still hasn't updated this project to the latest develop branch.
I get the following error message: Fatal error: Cannot set property 'language-team' of undefined
Hmm, that's strange. How are you checking the package to see if it updated? The only thing that's changed since the last release is this commit, so you'd have to see if any of that exists rather than checking a version number anywhere.
If that doesn't help, I may just have to go ahead and release that change. I was hoping to have it tested a little more.
Yeah, I'm checking the package inside the node_modules
and it's not updating.
Ahh, gotcha. That won't change since I haven't bumped versions. You should already have the dev version, so just try running grunt makepot
again and see if it updates those headers.
I keep getting this error: Fatal error: Cannot set property 'language-team' of undefined
In your processPot
callback, update those two header lines to this:
pot.headers['plural-forms'] = 'nplurals=2; plural=n != 1;';
pot.headers['language-team'] = 'Yoast Translate <translations@yoast.com>';
There was a missing "s" on headers
for the language team item, and I removed the newlines and an extra double quote.
Son of a .. that was the issue. Was too to damn focused on the output that I missed the obvious mistake. Thanks Brady!
No problem. Glad it worked!
I'll see about getting that change released soon so you don't have to jump through hoops to use it in the future. Thanks for helping test it out!
Just published this change in 0.4.2
Rather than opening a new ticket, I just read the above and implemented the above for bbPress :+1:
It works perfectly with the dev branch "grunt-wp-i18n": "git://github.com/blazersix/grunt-wp-i18n.git#develop"
I performed a npm cache clean
, changed back to v0.4.2 "grunt-wp-i18n": "~0.4.2",
and ran npm install
grunt-wp-i18n@0.4.2 node_modules\grunt-wp-i18n ├── underscore@1.5.2 ├── async@0.2.10 ├── underscore.string@2.3.3 └── gettext-parser@0.2.0 (encoding@0.1.7)
So it looks like grunt-wp-i18n v0.4.2 installed fine it just doesn't add the headers using v0.4.2?
Apparently I somehow forgot to merge the changes into the master
branch before tagging and publishing. Whoops! Let me see if I can re-tag it with the changes.
Thanks :wink:
I couldn't publish to npm using the same tag, so these changes are in 0.4.3 now. Give that a go and let me know if you run into any more issues.
Perfect, working as expected now thank you :+1:
Hey,
So I ran grunt with this configuration and the Report-Msgid-Bugs-To link was http://wordpress.org/support/plugin/flowplayer instead of http://wordpress.org/support/plugin/flowplayer5
Would it be possible to define the link for paid products that are not on the WordPress repo?