cedaro / grunt-wp-i18n

Internationalize WordPress themes and plugins with Grunt.
MIT License
160 stars 25 forks source link

Report-Msgid-Bugs-To link #7

Closed grappler closed 10 years ago

grappler commented 10 years ago

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

        makepot: {
            target: {
                options: {
                    domainPath: '/languages',    // Where to save the POT file.
                    mainFile: 'flowplayer.php',      // Main project file.
                    potFilename: 'flowplayer5.pot',   // Name of the POT file.
                    type: 'wp-plugin'  // Type of project (wp-plugin or wp-theme).
                }
            }
        },

Would it be possible to define the link for paid products that are not on the WordPress repo?

bradyvercher commented 10 years ago

Updating headers should be possible, but I'll have to find some time to add options to define those.

bradyvercher commented 10 years ago

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.

remkus commented 10 years ago

would this also work for adding header items that the i18n tools library don’t add themselves?

bradyvercher commented 10 years ago

@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.

remkus commented 10 years ago

Cool! Will check it out.

remkus commented 10 years ago

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.

bradyvercher commented 10 years ago

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

remkus commented 10 years ago

Hmm, couldn't make that work either. It's not actually updating to the develop branch when I put this in my package.jsonand run npm install:

"devDependencies": {
    "grunt": "~0.4.1",
    "grunt-wp-i18n": "git://github.com/blazersix/grunt-wp-i18n.git#develop"
  },
bradyvercher commented 10 years ago

It might be the cache. Try running npm cache clean before doing npm install.

remkus commented 10 years ago

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

bradyvercher commented 10 years ago

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.

remkus commented 10 years ago

Yeah, I'm checking the package inside the node_modules and it's not updating.

bradyvercher commented 10 years ago

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.

remkus commented 10 years ago

I keep getting this error: Fatal error: Cannot set property 'language-team' of undefined

bradyvercher commented 10 years ago

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.

remkus commented 10 years ago

Son of a .. that was the issue. Was too to damn focused on the output that I missed the obvious mistake. Thanks Brady!

bradyvercher commented 10 years ago

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!

bradyvercher commented 10 years ago

Just published this change in 0.4.2

ntwb commented 10 years ago

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?

bradyvercher commented 10 years ago

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.

ntwb commented 10 years ago

Thanks :wink:

bradyvercher commented 10 years ago

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.

ntwb commented 10 years ago

Perfect, working as expected now thank you :+1: